Question: Solve all three kindly: Note: Write codes/algorithm just for C or C++. Q6) Write an algorithm or a code to merge two linked lists of

Solve all three kindly:

Note: Write codes/algorithm just for C or C++.

Q6)

Write an algorithm or a code to merge two linked lists of students. The data part in each node of the first linked list, say male_list, consists of MALE students information (name, id, program). Similarly, the data part in each node of the other list, say female_list, consists of the information of FEMALE students. These linked lists should be merged such that, in the resultant_list no two MALE or FEMALE records are consecutive. Assume both input lists have equal length.

(hint: traverse both the lists step-by-step starting from their head nodes, and add item from appropriate list to the resultant list.)

Q7)

Write an algorithm or a code, which takes two sorted integer stacks intstack_1 and intstack_2 (with minimum value on top and the maximum value at the bottom) as input. The algorithm should output a single sorted stack result_stack of all the values (with the minimum value on top and the maximum value at the bottom). The algorithm should fulfill the following constraints:

  • Only stack operations are allowed, and they are already implemented (pop, push, top, isEmpty, isFull etc.).
  • No other data structure is allowed except stack.
  • The algorithm must work correctly for input stacks of different sizes.

Q8)

Assume that a queue int_queue is implemented using an integer array. Write an algorithm/code max_in_queue, which finds the maximum element in the queue. The algorithm should fulfill the following constraints.

  • Only queue operations are allowed, and they are already implemented (enqueue, dequeue, head, isEmpty, isFull etc.).
  • No other data structure is allowed except queues.
  • There should be no change in the queue after finding the maximum.

(hint: you will have to use an additional queue.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!