We have seen how to implement a queue using a linked list or a circular array. Another possible implemention will use two stacks, one for elements at the head of the queue and one for elements at the tail. Impelement a two-stack queue in Python and investigate its performance.
Write a function that prints out all values in a binary search tree in order, separated by spaces.
Modify your function to print out the tree values in reverse order.
Write a function that takes a binary tree and constructs a second tree that contains all the value from the first tree and is as balanced as possible.
Write a function that computes the sum of all values in a binary tree without using recursion.
Write a function that takes a binary tree and returns True if the tree satisfies the ordering requirements of a binary search tree.
Write a function that takes a binary tree and returns True if the tree is complete.
Write a function that returns the greatest difference between any two consecutive values in a binary search tree.
Write a function that takes a binary tree and returns True if the tree satisfies the ordering requirements of a binary heap.
Prove that we can convert an unordered array of N integers into a binary heap in time O(N) in the worst case. You may assume that N = 2k – 1 for some integer k.
Write a function that takes a undirected graph in adjacency matrix representation, and returns the same graph in adjacency list representation. Assume that the graph's vertices are numbered from 0 to (N – 1).
Write a function that takes a undirected graph in adjacency list representation, and returns the same graph in adjacency matrix representation. Assume that the graph's vertices are numbered from 0 to (N – 1).