Data Structures.
The median of a list is an element who has the same number of
predecessors and successors in the list, within a difference of 1
(for example, if the list contains 8 elements then the 4th and 5th
element are both medians). If the list has an even number of
elements, it has two medians; if the list has an odd number of
elements, then it has a single median.
a. Consider a doubly linked list, whose links are called fore and
back. We designate the head and tail of the list by pointers head
and tail. Give code that returns a median of the list, by using
link-hopping only (no counting of nodes).
b. Same question for singly linked list: Give code that returns a
median of a single linked list whose link is called fore. We
designate the head of the list by pointer head and we limit
ourselves to using link-hopping only (no counting of nodes).
Data Structures. The median of a list is an element who has the same number of predecessors and successors in the list,
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Data Structures. The median of a list is an element who has the same number of predecessors and successors in the list,
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!