Given a linked list with distinct elements, the task is to find the bitonic point in the given linked list. If there is no such point then print -1.
Input: 1 -> 2 -> 3 -> 4 -> 3 -> 2 -> 1 -> NULL
1 -> 2 -> 3 -> 4 is strictly increasing.
4 -> 3 -> 2 -> 1 -> NULL is strictly decreasing.
Input: 97 -> 98 -> 99 -> 91 -> NULL
Approach: A Bitonic Point is a point in bitonic sequence before which elements are strictly increasing and after which elements are strictly decreasing. A Bitonic point doesn’t exist if array is only decreasing or only increasing. So, find the first node such that the value of the node next to it is strictly smaller. Start traversing the linked list from that node onwards and if every other node is strictly smaller than its previous node then the found node was out bitonic sequence else the given linked list doesn’t contain a valid bitonic sequence. Note that an empty list or a list with a single node doesn’t represent a valid bitonic sequence.
Below is the implementation of the above approach:
- Point to next higher value node in a linked list with an arbitrary pointer
- Point arbit pointer to greatest value right side node in a linked list
- Create new linked list from two given linked list with greater element at each node
- XOR Linked List - A Memory Efficient Doubly Linked List | Set 1
- XOR Linked List – A Memory Efficient Doubly Linked List | Set 2
- Convert singly linked list into circular linked list
- Difference between Singly linked list and Doubly linked list
- Merge a linked list into another linked list at alternate positions
- Check if a linked list is Circular Linked List
- Convert Singly Linked List to XOR Linked List
- Write a function to get the intersection point of two Linked Lists
- Write a function to get the intersection point of two Linked Lists | Set 2
- Construct a Maximum Sum Linked List out of two Sorted Linked Lists having some Common nodes
- Create a linked list from two linked lists by choosing max element at each position
- Partitioning a linked list around a given value and If we don't care about making the elements of the list "stable"
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.