Regno: Name: Cse 102 - Data Structures and Algorithms - D1 & D2
Regno: Name: Cse 102 - Data Structures and Algorithms - D1 & D2
Name:
CSE 102 Data Structures and Algorithms D1 & D2
- Time required to make push and pop function calls for stack
- Data type specifies domain and range of data. Data structure represents the
structured way of storing and retrieving data.
4. In what way the deletion procedure differs for unsorted and sorted list?
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
B
6. What the term Linear refers to in Linear Data Structure.
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
7. What will happen if the stop condition is not given in recursion? Or will a recursive
call stops when the stop condition is not given?
- Yes the function stops after the system gets exhausted by allocation memory
required for the variables in each call
8 Char *p[3]; what this declaration means and what for p can be used?
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
- A pointer that pointer to the starting address of memory where the function is
stored
C
11. Differentiate pointer to an entire 2D array, pointer to the row and pointer to the
element with the example int *s, a[20][20]; s=a;
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
12. In what order the statements are executed in recursive function call.
- The statements before function call executes in sequence and statements after
the call executes out of sequence
13. What will happen here. Struct { int a; union{float b; char c;}, long d}*s1;
- a structure variable will get created where the memory will be allocated for
integer, float and long variables.
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
- If the statement to find the remainder of dividing the number by 2 is printed after
the recursive call, it will get printed in the reverse thereby printing the binary equivalent
of the decimal number.
D
16. State a drawback you feel with pointers.
-The pointers can be manipulated to access the memory beyond the scope of user
memory intended to be accessed thereby breaching the data security.
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
17. In what way the code for inserting an item in sorted and unsorted list differs.
- In sorted list, element to be inserted must be placed in the proper position such
that the resultant list must be in order. This is done by identifying the position and
pushing all the elements down. By doing so, a space gets created for the element to be
inserted. Whereas in unsorted list the element is inserted at the last position of the list.
18. What happens if a structure is created as follows struct stud{ int a; float b; struct stud
*p;}s1;
- The memory gets created for integer, float variable along with the pointer to the
same structure.
19. Is there a need that the pointer should be of the same type as that of variable it is
pointing to? Why?
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
- Yes, only then when the pointer is manipulated it can be shifted to appropriate
number of bytes depending on the type.
-Stalk DS is used in recursion because in recursion, the last call made must get
executed first. Since stack follows LIFO principle, stack is the correct choice for
recursion.
Quiz II
A
21 How will you handle the overflow condition of a linked stack through code?
Overflow need not be handles in linked stack of if a pointer to the new
node is null then overflow.
23 Draw a Doubly LL, assume some pointers for the nodes and explain how the
pointers are adjusted to insert a node "B" between "A" and "C" in a doubly linked
list.
Start curr and prev pointers and traverse the DLL such that curr points c
and Prev points A, then make newnode-> right= prev->right, prev>right=newnode, newnode->left= prev, curr->left=newnode. free(curr),
free(prev).
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
25 How to create a memory without a name during the execution of the program?
Using dynamic memory allocation functions like malloc()
Quiz II
B
26 How to perform priority dequeue in a queue?
Search for highest priority element and swap it with element at front and
then increment front.
27.Use a stack and convert the given expression into its postfix form (a+(b-c)*d).
Use stack and obtain the result : abc-d*+
28
How to traverse singly linked list in the reverse without using arrays?
Make it as a circular list and traverse till the end and print the last value.
Again go the beginning and traverse last but one and print its value so on
till the entire list is printed.
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
29 Write the set of statements for dequeing the last node of a linked queue.
Make the front to point front link. if front is null make rear also as null
Quiz II
C
31 What happens in a shell sort?
Different shell sizes are selected and insertion sort is performed.
32 How will you print the contents of a doubly linked list in reverse?
Traverse and reach the last node using the right pointers and start from the
last node, traverse using the left pointers and print the contents
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
35 What will be the complexity of quicksort when the pivot element is the least of
all?
Every time it may yield 2 arrays one with one element and other with all the
remaining elements. This results in extracting element by element out of the array
which will get complexity O(n2).
Quiz II
D
36 What is the return type of malloc function? Justify the answer.
void * to accept pointer to any type of memory created.
38 Write the set of statements for creating the first node of a linked queue.
create a newnode at rear. Make front also to point the new node.
RegNo:
Name:
CSE 102 Data Structures and Algorithms D1 & D2
Take the elements and insert them into queue based on their priority.