Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Data structure - Interview Questions and Answers for 'Compro technologies' - 5 question(s) found - Order By Newest | ||||
| ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. First Find the number of nodes in the linked list and take it as n.then find the data at n-3 element. | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
Ans. import java.util.*; class LinkedListSolution{ protected LinkedList list; public LinkedListSolution(){ list = new LinkedList(); } public Object pop() throws NoSuchElementException{ if(list.isEmpty()) throw new NoSuchElementException(); else return list.removeFirst(); } public void push(Object obj){ list.addFirst(obj); } public Object peek() throws NoSuchElementException{ if(list.isEmpty()) throw new NoSuchElementException(); else return list.getFirst(); } public boolean isEmpty(){ return list.isEmpty(); } public String toString(){ return list.toString(); } } class TestStack{ public static void main(String args[]){ LinkedListSolution s = new LinkedListSolution(); s.push("First"); s.push("Second"); s.push("Third"); System.out.println("Top: " s.peek()); s.push("Fourth"); while(!(s.isEmpty())) System.out.println(s.pop()); } } | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
| ||||
Ans. We can merge two sorted array by using quick sort algorithm | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||
| ||||
![]() | ||||
![]() | ||||
![]() ![]() ![]() ![]() | ||||