functions (3.papers)

loops (1.papers)

Conditional statements (2.papers)

arrays (2.papers)

structures (3.papers)

unions (1.papers)

Enums and TypeDefs (3.papers)

pointers (7.papers)

null pointers (1.papers)

strings (2.papers)

misc c concepts (1.papers)

Data structures (5.papers)

linked lists (3.papers)

trees (1.papers)

basics (5.papers)

bitwise operators (1.papers)

1

data structures in c: What operation below function is doing? And which data structure is this? #define MAX_ELE 10 //assume maximum elements is 10 int cur; //points to current top element. int fun (int ds[]) { int val; if (cur == -1) { val = -1; } else { val = ds [cur]; --cur; } return val; }

this function is trying to retrieve an existing element from the array ds[]. here ds is an array data structure.

this function is trying to retrieve an existing element from top location of this data structure. So this is a stack. and operation here is pop operation.

this function is trying to retrieve an existing element from starting location of this data structure. So this is a stack. and operation here is pop operation.

this function is trying to retrieve an existing element from starting location of this data structure. So this is a queue. and operation here is deletion operation on queue.

Show Answer

2

assume below things #define MAX_ELE 10 //assume maximum elements is 10 int cur; //points to current top element. and Which of the below function are correct implementation of a stack pop() function?

int fun (int ds[]) { int val; if (cur == -1) { val = -1; } else { val = ds [cur]; --cur; } return val; }

int fun (int ds[]) { int val; if (cur == MAX_ELE) { val = -1; } else { val = ds [cur]; ++cur; } return val; }

int fun (int ds[]) { int val; if (cur == 0) { val = -1; } else { val = ds [cur]; --cur; } return val; }

int fun (int ds[]) { int val; if (cur == 0) { val = -1; } else { val = ds [--cur]; } return val; }

Show Answer

Show Answer

4

Which of the below is not an example of a queue? i. persons standing in a line in a movie ticket booking center. ii. set of programs waiting to get the attention of CPU to get executed. iii. set of plates in a hotel.

i

ii

iii

all are examples of a queue.

Show Answer

Show Answer

6

what is deque in c? (hint:double )

removing element from the queue is called as deque.

inserting an element into the queue is called as deque

double ended queue, where we can insert and delete elements at both the ends.

double ended queue, where we can insert at only end but we can delete from both the ends.

Show Answer

7

what is enqueue in c?

inserting element into the queue is called as enqueue operation.

queue where we can insert and delete at only one end is called as enqueue.

queue where we can insert and delete at the same end is called as enqueue.

queue where we can insert at only one end but can delete from any end.

Show Answer

8

which of the below is not a queue? i. circular queue ii. deque iii. priority queue

i

ii

iii

all are types of a queues.

Show Answer

9

How to implement a queue in c? i. array ii. single linked list iii. double linked list.

i

i or ii

i or ii or iii

i or iii

Show Answer

10

In a queue with elements c,b,a , where c is in front and a in the rear. If we perform enqueue(d), then how does the queue look like?

d,c,b,a

c,b,a,d

either option 1 or option 2, we can't say

none of the above

Show Answer

11

In a queue with elements (front)c,b,a(rear) and if we perform enqueue(d), dequeue(), enqueue(e), then how does it look like?

b,a,d,e

c,b,d,e

e,d,c,b

c,b,a,e

Show Answer

12

What is the time complexity of implementing a queue using a double linked list in c?

O(n)

O(log n)

O(1)

O(n^2)

Show Answer

Show Answer

14

How to implement a deque data structure efficiently in c? i. by using dynamic array ii. by using static array iii. double linked list. iv. single linked list.

i

ii

i or iii

i or iv

Show Answer

15

What is a bounded queue in c?

Queue of fixed no of items.

Queue of unlimited no of items.

Queue which will not allow the value to be more than a bound value.

Queue which will allow the value to be always more than a bound value.

Show Answer

16

linked list example in c: What is below function fun() doing? what is the operation, and what is this data structure? struct node { int data; struct node *link; }*head=NULL; void fun(int val) { struct node *temp = NULL; temp=(struct node *)malloc(sizeof(struct node)); temp->data=val; temp->link=head; head=temp; }

function fun() is trying to insert a new element into the singly linked list. operation here is insertion to the single linked list. data structure here is linked list.

function fun() is trying to insert a new element at the end of previous element. this operation is a push operation on stack(as we insert new elements in stack at the end). this data structure is implementation of push operation of stack using a linked list.

function fun() is trying to insert a new element at the end of previous element. this operation is a push operation on queue(as we insert new elements in queue at the end). this data structure is implementation of insert() operation of queue using a linked list.

it can be either option 2 or 3.

Show Answer

17

Demo code for linked list in c: What is below function disp() doing? what is the operation, and what is this data structure? assume that head is always pointing to the latest element added at the end. struct node { int data; struct node *link; }*head=NULL; void disp() { struct node *temp; if(head==NULL) printf("data structure is empty\n"); else { temp=head; printf("retrieving... %d\n",temp->data); free(temp); head=head->link; } }

disp is removing top(end) element from this data structure. so it is a pop() operation of a stack using linked list.

disp is removing top element from this data structure. so it is a remove() operation of a queue using linked list.

disp is removing first element from this data structure. so it is a pop() operation of a stack using linked list.

disp is removing first(old) element from this data structure. so it is a remove() operation of a queue using linked list.

Show Answer

18

What is below function move() doing? What is the name this famous program? For which data structure, this is an example? void move(int n,char *s,char *i,char *d) { if(n>0) { move(n-1,s,d,i); printf("moving %d disk from %S to %s", n, s, d); move(n-1,i,s,d); } }

move is recursive function call to move 'n' number of rings from source 's' to destination 'd' towers respectively. this is famous towers of hanoi program. this is an example of stack architecture.

move is recursive function call to move 'n' number of rings from source 's' to destination 'd' towers respectively. this is famous towers of hanoi program. this is an example of queue architecture.

move is recursive function call to move 'n' number of rings from source 's' to destination 'i' towers respectively. this is famous towers of hanoi program. this is an example of stack architecture.

move is recursive function call to move 'n' number of rings from source 's' to destination 'i' towers respectively. this is famous towers of hanoi program. this is an example of queue architecture.

Show Answer

19

in what order parameters passed to a function will be stored in the system's stack segment? eg: If a function is taking 3 arguments int a, int b, int c . .like fun(int a, int b, int c){..} then when some body makes a call to this function with three parameters fun(x,y,z); then in what order these 3 variables will be stored in stack segment?

stack will store in x,y,z order.. where z is the top most element inserted and it is the top most element to be popped out.

stack will store in z,y,x order.. where x is the top most element inserted and it is the top most element to be popped out.

it can be either option 1 or option2 but there is no guarantee.

it really doesn't matter in which order it is going to store.

Show Answer

20

when a function calls other function in c language, then where does PC(program counter) will be stored? on top of the stack or below the local variables?

first local variables will be stored in the stack of that function, and then on the top PC will be stored.

first PC will be stored, and then the local variables of that function.

it can be either option 1 or option2 but there is no guarantee.

it really doesn't matter in which order it is going to store.

Show Answer