Home/data structure interview questions and answers
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Write the steps involved in the insertion and deletion of an element in the stack.
Push: Increment the variable top so that it can refer to the next memory allocation Copy the item to at the array index value equal to the top Repeat steps 1 and 2 until the stack overflows Pop: Store the topmost element into the another variable Decrement the value of the top Return the topmost eleRead more
Push:
Pop:
What is a postfix expression?
An expression in which operators follow the operands is known as postfix expression. The main benefit of this form is that there is no need to group sub-expressions in parentheses or to consider operator precedence. The expression "a + b" will be represented as "ab+" in postfix notation.
An expression in which operators follow the operands is known as postfix expression. The main benefit of this form is that there is no need to group sub-expressions in parentheses or to consider operator precedence.
The expression “a + b” will be represented as “ab+” in postfix notation.
See lessWrite the postfix form of the expression: (A + B) * (C – D)
AB+CD-*
See lessAB+CD-*
How to reference all the elements in a one-dimension array?
It can be done by using an indexed loop such that the counter runs from 0 to the array size minus one. In this manner, you can reference all the elements in sequence by using the loop counter as the array subscript.
It can be done by using an indexed loop such that the counter runs from 0 to the array size minus one. In this manner, you can reference all the elements in sequence by using the loop counter as the array subscript.
See lessHow are the elements of a 2D array are stored in the memory?
There are two techniques by using which, the elements of a 2D array can be stored in the memory. Row-Major Order: In row-major ordering, all the rows of the 2D array are stored in the memory contiguously. First, the 1st row of the array is stored in the memory completely, then the 2nd row of the arrRead more
There are two techniques by using which, the elements of a 2D array can be stored in the memory.
Calculate the address of a random element present in a 2D array, given base address as BA.
Row-Major Order: If the array is declared as a[m][n] where m is the number of rows while n is the number of columns, then the address of an element a[i][j] of the array stored in row-major order is calculated as, Address(a[i][j]) = B. A. + (i * n + j) * size Column-Major Order: If the array iRead more
Row-Major Order: If the array is declared as a[m][n] where m is the number of rows while n is the number of columns, then the address of an element a[i][j] of the array stored in row-major order is calculated as,
Address(a[i][j]) = B. A. + (i * n + j) * size
Column-Major Order: If the array is declared as a[m][n] where m is the number of rows while n is the number of columns, then the address of an element a[i][j] of the array stored in column-major order is calculated as
Address(a[i][j]) = ((j*m)+i)*Size + BA.
See lessAre linked lists considered linear or non-linear data structures?
A linked list is considered both linear and non-linear data structure depending upon the situation. Based on data storage, it is considered a non-linear data structure. Based on the access strategy, it is considered a linear data structure.
A linked list is considered both linear and non-linear data structure depending upon the situation.
What are the advantages of Linked List over an array?
The size of a linked list can be incremented at runtime which is impossible in the case of the array. The List is not required to be contiguously present in the main memory, if the contiguous space is not available, the nodes can be stored anywhere in the memory connected through the links. The ListRead more
Write the syntax in C to create a node in the singly linked list.
struct node { int data; struct node *next; }; struct node *head, *ptr; ptr = (struct node *)malloc(sizeof(struct node));
See lessstruct node
{
int data;
struct node *next;
};
struct node *head, *ptr;
ptr = (struct node *)malloc(sizeof(struct node));
If you are using C language to implement the heterogeneous linked list, what pointer type should be used?
The heterogeneous linked list contains different data types, so it is not possible to use ordinary pointers for this. For this purpose, you have to use a generic pointer type like void pointer because the void pointer is capable of storing a pointer to any type.
The heterogeneous linked list contains different data types, so it is not possible to use ordinary pointers for this. For this purpose, you have to use a generic pointer type like void pointer because the void pointer is capable of storing a pointer to any type.
See less