search
Log In

Recent questions tagged linked-lists

4 votes
4 answers
1
In a doubly linked list the number of pointers affected for an insertion operation will be 4 0 1 Depends on the nodes of doubly linked list
asked May 7, 2017 in DS sh!va 7.9k views
4 votes
1 answer
2
I was trying to implement the Linked List code in C. It compiles fine but doesn't give any output. What seems to be the error? I think I messed up at passing pointer references as function parameters. My Code (Insert At Beginning): #include <stdio.h> ... to the head node(pointer to pointer) to the function. - Return the modified head node by the function. Please read about Reference Semantics.
asked Apr 26, 2017 in Programming RahulVerma 330 views
62 votes
9 answers
3
Consider the C code fragment given below. typedef struct node { int data; node* next; } node; void join(node* m, node* n) { node* p = n; while(p->next != NULL) { p = p->next; } p->next = m; } Assuming that m and n point to valid NULL-terminated linked ... or append list m to the end of list n. cause a null pointer dereference for all inputs. append list n to the end of list m for all inputs.
asked Feb 14, 2017 in DS khushtak 13.4k views
0 votes
4 answers
4
struct node{ int num; struct node *next; } void print(struct node *ptr) { if(ptr) { printf("%d",ptr->data); do{ printf("%d",ptr->data); } while(ptr->next); } } What is the output, if a $SLL : 1\rightarrow 2\rightarrow 3\rightarrow 4\rightarrow 5$ is passed in the above $C$ code ? Assume Head pointer at Node $1$
asked Feb 3, 2017 in DS Kapil 577 views
6 votes
2 answers
8
Time complexity to insert a node in the end of circular linked list, if the pointer to the 1st node is given and number of nodes in list is N is A)O(1) B)O(log N) C)O(N) D)O(N log N)
asked Jan 13, 2017 in DS srestha 1.1k views
1 vote
1 answer
9
In a doubly linked list organization, insertion of a record in end involves modification of ____ for existing list. one pointer two pointer multiple pointer no pointer
asked Jan 4, 2017 in DS srestha 960 views
1 vote
1 answer
10
The Answer given is A) I think the naswer should be B) as we have both the prev pointer and the next pointer available , it will take constant time to update the adjacent nodes pointers and delete the given node .?
asked Jan 3, 2017 in DS Harsh181996 963 views
22 votes
2 answers
11
Write a constant time algorithm to insert a node with data $D$ just before the node with address $p$ of a singly linked list.
asked Dec 17, 2016 in DS Arjun 1.2k views
2 votes
1 answer
12
Provide short answers to the following questions: Express the following list in terms of a linked list structure suitable for internal representation. $(((ab)c)d((e)))$
asked Nov 30, 2016 in DS makhdoom ghaya 352 views
1 vote
1 answer
13
asked Nov 25, 2016 in DS thor 133 views
2 votes
1 answer
14
asked Nov 19, 2016 in DS thor 1.2k views
9 votes
3 answers
15
A list of $n$ elements is commonly written as a sequence of $n$ elements enclosed in a pair of square brackets. For example. $[10, 20, 30]$ is a list of three elements and $[]$ is a nil list. Five functions are defined below: $car (l)$ returns the first element of its argument list $l$; $cdr (l)$ ... $f ([32, 16, 8], [9, 11, 12])$ (b) $g ([5, 1, 8, 9])$
asked Nov 14, 2016 in DS makhdoom ghaya 1.2k views
15 votes
3 answers
16
In a circular linked list oraganisation, insertion of a record involves modification of One pointer. Two pointers. Multiple pointers. No pointer.
asked Nov 8, 2016 in DS makhdoom ghaya 6k views
0 votes
0 answers
17
I am not getting how unsigned is used and how is it working???
asked Nov 5, 2016 in Programming Rahul Jain25 170 views
0 votes
0 answers
18
Let P be a singly linked list. Let Q be the pointer to an intermediate node X in the list. What is the worst case time complexity of the best known algorithm to delete node X from the list? A) O(n) B) O(log 2 n) C) O(log n) D) O(1)
asked Oct 27, 2016 in DS Sankaranarayanan P.N 116 views
4 votes
1 answer
19
Consider the following incomplete C function for reversing a singly linked list. node* reverse(node* trav){ if(trav->next) __________________ else { head -> next = null; head = trav; } return trav; } Here, head is a global pointer pointing to the head of the list and where the head ... reverse(trav->next) -> next = trav; trav->next -> next = trav; trav -> next = trav; trav = reverse(trav->next);
asked Oct 19, 2016 in Programming Arjun 589 views
2 votes
0 answers
20
Assume that you have a semaphore associated with each item on a doubly linked list. Using No other synchronization primitive, What is the fewest number of semaphore that you must acquire for any operation (lookup, insert, delete) ?
asked Oct 11, 2016 in Operating System mcjoshi 522 views
2 votes
2 answers
21
Two linked lists having n and m elements are stored in sorted order. What is the worst case complexity of program to print common elements of two lists ? $\begin{align*} &A. \ \ O(n) \\ &B. \ \ \text{max}(m,n) \\ &C. \ \ \text{min}(m,n) \\ &D. \ \ m+n \end{align*}$
asked Sep 27, 2016 in Algorithms Vishal Goyal 309 views
0 votes
1 answer
22
Consider an implementation of unsorted single linked list. Suppose it has its representation with a head and a tail pointer (i.e. pointers to the first and last nodes of the linked list). Given the representation, which of the following operation can not be implemented in ... the end of the linked list. Deletion of the front node of the linked list. Deletion of the last node of the linked list.
asked Sep 25, 2016 in DS makhdoom ghaya 710 views
0 votes
1 answer
23
Q)The below code returns decimal value of binary linked list int val(struct Node *head) { struct Node *p = head; int val2= 0; while (p!= NULL) { XYZ;//fill the contents of XYZ p = p→next; } return val2; } What is XYZ in above code ? Please provide a sound explaination too.
asked Sep 23, 2016 in DS Manikant Kumar 274 views
0 votes
1 answer
24
To insert a node at the end of double linked list we need to modify two pointers right??But answer given is one pointer. can someone clarify?
asked Sep 9, 2016 in Programming cse23 252 views
3 votes
1 answer
25
Consider the following algorithm to build a balanced search tree from a sorted sequence. * Make the mid-point of the sequence the root of the tree * Recursively construct balanced search trees from elements to the left and right of the midpoint and make these the left and right subtrees of the ... a sorted array? 1- O(n) 2- O(n log n) 3- O(n2) 4- Depends on the contents of the original sequence
asked Aug 23, 2016 in Algorithms dd 747 views
...