DSA FINALS

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

a. True

A pointer can be used to access elements of an array

empty

If front=rear ,then the queue is?

a. True

The operator * is used to get value stored at an address that is pointed by a pointer

Pointers

- A special pointer is a special variable, it isspecial because it can only contain as its value amemory address. - A pointer provides an indirect way to access thevalue stored in the memory where it points. - A variable that holds a memory address ofanother object

Dequeue

A data structure in which elements can be inserted or deleted at/from both the ends but not in the middle is?

FILO

Are stacks FIFO or FILO?

a. 98

What does the variable i contain after the following code executes? int i = 17; int *p = &i; *p = 98;

c. j is a pointer to an int and stores address of i

Which of the statements is correct about the program? int main() { int i=10; int *j=&i; return 0;}

vertices, paths

A graph is a collection of nodes, called .......... And line segments called arcs or ........... that connect pair of nodes.

Rear = MAX_SIZE - 1

A normal queue, if implemented using an array of size MAX_SIZE, gets full when

pointer

A variable that holds a memory address of another object.

Ancestor node

Any node is the path from the root to the node is called

5

Consider the following operation performed on a stack of size 5. Push(1); Pop(); Push(2); Push(3); Pop(); Push(4); Pop(); Pop(); Push(5); After the completion of all operation, the no of element present on stack are

b. ->

If a variable is a pointer to a structure, then which of the following operators is used to access data members of the structure through the pointer variable?

5

In a circular queue of size 7 if front index=5 and rear index =3 then ___ dequeue operations has been performed.

only one element left in the queue.

In a nonempty queue if front=rear, it means

front is NULL

In linked list implementation of a queue, the important condition for a queue to be empty is?

front = 2 rear = 5 queue = ______; L, M, N, O, ___

Let the following circular queue can accommodate maximum six elements with the following data front = 2 rear = 4 queue = _______; L, M, N, ___, ___ What will happen after ADD O operation takes place?

loading or lifetime

Static allocation binds memory space to variables at

p2=&k;

Supply the missing program code/codes int i = 2; int k = 4; int *p1; int *p2; p1 = &i; ________ p1 = p2; *p1 = 6; *p2 = 8; cout << i <<"\t" <<k; OUTPUT : 2 8

b. the number of bytes needed to store an int variable

The expression sizeof(int) refers to

- +pq * rt

The prefix form of an infix expression p + q - r * t is?

postfix expression

The type of expression in which operator succeeds its operands is?

a. b.var;

Which of the following accesses a variable in structure b?

b. struct a_struct {int a;};

Which of the following is a properly defined struct?

D) Trees

Which of the following is non-liner data structure?

a. True b. False

A pointer variable is the variable that can store the address of a variable?

(A B D ⋀ + E F - / G +)

Convert the following infix expressions into its equivalent postfix expressions (A + B ⋀D)/(E - F)+G

a. True

The address operator(&) is used to get the address of a variable by putting it in front of the variable

AB*CD/+

The postfix form of A*B+C/D is?

Linked list

A linear collection of data elements where the linear node is given by means of pointer is called?

First node

Consider the linked list implementation of a stack. Which of the following node is considered as Top of the stack?

Depth First

In the ................. traversal we process all of a vertex's descendants before we move to an adjacent vertex

delete

It destroys or de-allocate a dynamic variable to some other data

c. &a;

Which of the following gives the memory address of integer variable a?

Address of 2nd Node

what will "current" contain if it is a pointer to a variable of type struct node ?

Compile time

Static allocation binds memory space to variables at ___

oveflow

The essential condition which is checked before insertion in a linked queue is?

overflow

The essential condition which is checked before insertion in a linked queue is?

X

What is the result of the following operationTop (Push (S, X))

Traversal

is not the operation that can be performed on queue.

head

A linked list contains a list pointer variable _____that stores the address of the first node of the list.

c, d, W, X, Y

A queue of characters currently contained a,b,c,d. What would be the contents of queue after the following operation DELETE, ADD W, ADD X, DELETE, ADD Y.

b. False

An address stored by a pointer can be specified by the programmer

9

Consider the following array implementation of stack:#define MAX 10Struct STACK{Int arr [MAX];Int top = -1;}If the array index starts with 0, the maximum value of top which does not cause stack overflow is?

1

Consider the following operations performed on a stack of size 5 : Push (a); Pop() ; Push(b); Push(c); Pop(); Push(d); Pop(); Pop(); Push (e) Which of the following statements is correct?

xyz*+pq*r+s*+

Convert the following Infix expression to Postfix form using a stack x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.

b. Both Emp.emName; and Emp->emName;

Given a structure definition, a member of the structure can be accessed by one of the following statements: struct Employee{ string emName; string emSex; string emAddress; int emSalary; }; Employee Emp;

d. arr = 7.7;

Given the following variable and array declarationsfloat arr[] = {1.0, 2.1, 3.2, 4.3, 5.4, 6.5, 7.6, 8.7};float * ptr1, *ptr2;which of the following assignments is not allowed?

ABCD

If the elements "A", "B", "C" and "D" are placed in a queue and are deleted one at a time, in what order will they be removed

d,c,b,a

If the elements "D, "C", "B" and "A" are placed in a queue and are deleted one at a time, in what order will they be removed?

5

If the numbers 5, 10, 3, 42 are enqueued onto a queue in that order, what does dequeue return?

Linear search

In ..............., search start at the beginning of the list and check every element in the list.

b. False

In C++ language, a function can't return a pointer.

b. False

In C++, we can declare a structure using the "structure" keyword.

b. False

In C, when an array is passed to a function, the address and a value of the array are passed to the function.

(rear+1) % Number of Item

In a circular queue, how do you increment the rear end of the queue?

front

In linked list implementation of a queue, from where is the item deleted?

front = null , rear = null.

In linked list implementation of a queue, the important condition for a queue to be empty is?

rear

In linked list implementation of a queue, where does a new element be inserted?

Queues use two ends of the structure; stacks use only one.

One difference between a queue and a stack is:

True

Queue can be implemented using a list?

*p1 = *p2;

Supply the missing program code/codes int i = 23; int j = 72; int *p1; int *p2; p1 = &i; p2 = &j; __________ cout << i <<" "; cout<<j; OUTPUT : 72 72

Linked Lists

The advantage of ................. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists.

Rear value

The essential condition which is checked before insertion in a linked queue is?

C

The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is

b. False

The following code swaps two consecutive elements in an integer array a[ i ] = a[ i + 1 ]; a[ i + 1 ] = a[ i ];

LO+ VE*R - FG /**

The postfix form of the expression (L+ O)*(V*E- R)*F / G is?

The right subtree can be empty

The property of binary tree is

350

The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?

stack

What data structure can be used to check if a syntax has balanced parenthesis ?

b. An array of 250 pointer to floats

What data structure, in words, does the following declaration declare? float * measures[250];

Prints all nodes of linked list in reverse order

What does the following function do for a given Linked List with first node as head? void wow(node* head) { if (head == NULL) return; wow(head -> next); cout << head -> data; }

Front, Rear

What is examples of variable being used to certain algorithm to implement Queue in Array ?

Inserting a node at the end of the list

What is the functionality of the following code? public void function(Node node) { if(size == 0) head = node; else { Node temp,cur; for(cur = head; (temp = cur.getNext())!=null; cur = temp); cur.setNext(node); } size++; }

Find and return the position of the given element in the list.

What is the functionality of the following piece of code? public int function(int data) { Node temp = head; int var = 0; while(temp != null) { if(temp.getData() == data) { return var; } var = var+1; temp = temp.getNext(); } return Integer.MIN_VALUE; }

reuse empty spaces

What is the reason for using a "circular queue" instead of a regular one?

overflow

What is the term for inserting into a full queue known as?

deQueue()

Which is the correct operation for: "Remove the front item from the queue and return it"

b. arr[5] and (ptr + 4)[1]

Which of the following are equivalent, assuming that arr is an integer array and that ptr is an integer pointer pointing to the start of the array?

A) finding factorial B) tower of Hanoi C) infix to postfix conversion D) all of the above

Which of the following is an application of stack?

A) Insertion Sort B) Bubble Sort C) Merge Sort D) Heap Sort

Which of the following is not the internal sort?

d. A structure can't have arrays in it.

Which of the following statements about the structure is not true?

Calculate the size of a linked list

int count = 0; NodeType * current = head; while (current !=NULL) { count++; current = current -> link; } return count; What is the operation of the above statements?

Memory Allocation

is an operation wherein a specified amount of memory space is reserved for storage of data.


Ensembles d'études connexes

NUR 334 EXAM 2: random questions

View Set

MARK4450 Test 2 Founders of Social

View Set

mental health theroies & therapy

View Set

Anatomy 25-SYSTEMATIC ANATOMY: REPRODUCTIVE SYSTEMS

View Set

Chapter 21: Drugs for Neuromuscular Disorders and Muscle Spasms

View Set