This article shares some typical questions that are likely to be asked during a Software Engineering position interview. Prepare for it by understanding each topic.
Although the two programming languages are very similar, there are some subtle differences that you should be aware of. Make sure you are comfortable with each programming language.
In Java, there is a garbage collection thread that periodically collects any unused objects for cleaning. There is no garbage collection in C++; instead, the programmer must explicitly clean up after his or her objects.
C++ allows for multiple inheritance, Java allows for only single inheritance (extending a single class) but can implement multiple interfaces.
A process is a particular instance of a running application/program, it has its only memory space. Likewise, a thread is an instance of a particular program's code, but is not considered an application/program even if the program is singlethreaded.
For this reason, a process may contain one or more threads.
One important difference is that threads (within the same process) is permitted to share data and access one another's stack and memory space. Whereas, a process can only communicate with other processes using inter-process communications such as pipes, files, or sockets.
A simple approach would be to iterate the list to count how many nodes are in the list and then do a second iteration to stop at the nth last node. This is, unfourtunately, unnecessary.
Instead, we can use a smarter approach. We use two pointers, p1 and p2, where p1 points to the node that is n-1 nodes before p2. Initially, we set p1 and p2 to the head of the list, then iterate p2 n-1 nodes ahead. Then in the second loop, we iterate both p1 and p2. When p2 hits the null node, p1 points to the nth last node, so just return p1 as the answer. If the list does not contain n nodes, then you can return some message during the first loop.
We will use two pointers, p1 and p2, where p1 will advance one node and p2 will advance two nodes. The idea is that, if p2 advances twice as fast, it will see p1 eventually (if the list is circular). Make sure to check if p2 points to a null entry in case the list is not circular.
After learning each of these topics, you should more confident in answering programming interview questions.
scgAnO Very good blog.Thanks Again. Keep writing.
Appreciate you sharing, great blog post.Really looking forward to read more.
Im thankful for the blog post.Really looking forward to read more. Much obliged.
Very neat article.Much thanks again. Cool.
Thanks again for the post.Much thanks again. Really Cool.