Tag: sorted
Converting a Binary Search Tree to a Sorted Doubly Linked List
Change the left and right pointers of each node in Binary search Tree to make it a sorted doubly linked list. Method: Just do the Post order traversal and while visiting the node, Advertisements    Point the left link of visiting node to right most node in left tree.    Point the right link of …
Converting a Binary Search Tree to a Sorted Doubly Linked ListRead More
Remove Duplicate Elements from a Sorted Singly Linked List
Lets remove all duplicate elements from a sorted singly linked list. For example, Advertisements Suppose given linked list contains following elements in given order, 1, 2, 3, 4, 4, 5, 6, 7, 7, 7, 7, 9, 89 Frequently Asked: Reverse a Singly Linked List in a Single Iteration Create a Singly Linked List from an …
Remove Duplicate Elements from a Sorted Singly Linked ListRead More
Python : Sort a List of numbers in Descending or Ascending Order | list.sort() vs sorted()
In this article we will discuss how to sort a list of numbers in ascending and descending order using two different techniques. list.sort() vs sorted() list’s sort() function In Python, list provides a member function sort() that can sorts the calling list in place. Advertisements sorted() Function It’s a built in function that accepts an …
Python : Sort a List of numbers in Descending or Ascending Order | list.sort() vs sorted()Read More
Python: Iterate over a dictionary sorted by value
In this article, we will learn different ways to iterate over a python dictionary sorted by value in both the assending and descending order. Iterate over a python dictionary sorted by value using sorted() Iterate over dictionary sorted by value in ascending order To iterate over a dictionary sorted by custom logic, we need to …
Python: Iterate over a dictionary sorted by key
In this article, we will learn different ways to iterate over a python dictionary sorted by key in both the assending and descending order. Table of Contents: Iterate over a python dictionary sorted by key using sorted(). Iterate over dictionary sorted by keys using items(). Iterate over dictionary sorted by key using comparator / lambda …
Python: Get list of files in directory sorted by date and time
In this article, we will discuss different ways to get list of all files in a directory / folder sorted by date and time in python. Table of contents Get list of files (file paths) in directory sorted by date. Get list of file names in directory sorted by date. Get list of files (file …
Python: Get list of files in directory sorted by date and timeRead More
Python: Get list of files in directory sorted by size
In this article, we will discuss different ways to get list of all files in a directory / folder sorted by size. Table of contents Get list of files (file paths) in directory sorted by size. Get list of file names in directory sorted by size. Get list of files (file paths) in directory and …
Python: Get list of files in directory sorted by sizeRead More
Python: Get list of files in directory sorted by name
In this article, we will discuss different ways to get list of all files in a directory / folder sorted by name in python. Table of contents Get list of files (file paths) in directory sorted by name. Get list of file names in directory sorted by name. Get list of files (file paths) in …
Python: Get list of files in directory sorted by nameRead More
How to check if an Array is Sorted in C++
In this article, we will discuss different ways to check if an array is sorted or not in C++. Table Of Contents Problem Description Check if array is sorted using std::adjacent_find() Check if array is sorted using std::is_sorted() Check if array is sorted using Recursive Approach Check if array is sorted using Iterative Approach Summary …
Get the indices of sorted List in Python
In this article, we will discuss different ways to get the indices of sorted List in Python. Table Of Contents Introduction Get the indices of sorted List using sorted() function Get the indices of sorted List using enumerate() & sorted() Get the indices of sorted List using NumPy Summary Introduction Suppose we have a list …