Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions