Question

In: Computer Science

In Java programing : Q1-A Deque supports operations, addFront(), addRear(), removeFront() and removeRear(). Given stacks and...

In Java programing :

Q1-A Deque supports operations, addFront(), addRear(), removeFront() and removeRear(). Given stacks and their push() and pop() operations only, what are the minimum number of stacks required for this implementation?

A-1, B-2, C-3, D-4,

Q2- True or false and why

The height of a random binary tree with 100 nodes can range from 7 to 100.?

Q3-One can convert a binary tree into its mirror image by swapping each node's left and right childern while traversing it in _______?.

Q4-How to calculate number of node by tree height ?

Q5-The complexity of using sequential search algorithm on a sorted list of n items is ____.

Q6-The data structure that allows deletions at both ends of the list but insertion at only one end is ________. < Which type ?

Q7-What will be the maximum number of comparisons needed with a binary search to find a particular customer's record from a sorted list of 100 records?

Q8-For an array containing 8 elements as: 42, 29, 75, 11, 65, 58, 60, 18, what will be the result of sorting it in ascending order using bubble sort after 2 passes have completed?

Solutions

Expert Solution

(2)The height of a random binary tree with 100 nodes can range from 7 to 100.(True)
considering height of tree is equal to maximum number of nodes in longest path from root to leaf.
If there are n nodes in binary tree, maximum height of the binary tree is n and minimum height is floor(log2n) + 1.
Here maximum height = 100
minimum height = floor(log2100) + 1= 7
Range of height from 7 to 100

Q3-One can convert a binary tree into its mirror image by swapping each node's left and right childern while traversing it in post order.

Q4-calculate number of node by tree height
Let the height of tree be h.
minimum number of nodes = h
maximum number of nodes = 2^(h) - 1

Q5-The complexity of using sequential search algorithm on a sorted list of n items is O(n).

Q6-The data structure that allows deletions at both ends of the list but insertion at only one end isInput restricted dequeue

Q7-The maximum number of comparisons needed with a binary search to find a particular customer's record from a sorted list of 100 records
it is equal to number of nodes = 100

Q8-For an array containing 8 elements as: 42, 29, 75, 11, 65, 58, 60, 18
Arr[] = {42, 29, 75, 11, 65, 58, 60, 18}
After first pass {29, 42, 11, 65, 58, 60, 18, 75}
After second pass {29, 11, 42, 58, 60, 18, 65, 75}


Related Solutions

A deque (short for double-ended queue, but pronounced “deck”) is an abstract data type that supports...
A deque (short for double-ended queue, but pronounced “deck”) is an abstract data type that supports adding and removing at both the front and back. So, at a bare minimum, a deque has four operations: addFront(), removeFront(), addBack(), removeBack(). Suppose you have a deque D containing the numbers (1, 2, 3, 4, 5, 6, 7, 8), in this order. Suppose further that you have an initially empty queue Q. Give pseudo-code description of a method that uses only D and...
Describe how stacks and their main operations can be implemented using arrays and stacks. Provide the...
Describe how stacks and their main operations can be implemented using arrays and stacks. Provide the pros and cons for each approach. Research some applications, that can use stacks as a possible implementation vehicle.
JAVA- List, Stacks, Queues, Sets, And Maps Question 1 Given that you want to be able...
JAVA- List, Stacks, Queues, Sets, And Maps Question 1 Given that you want to be able to return the items that come immediately before and after a given node. Which variation of a list would be best suited? 1. Circular single-linked list 2. All options are equally good 3. Double linked list 4. Single linked list with header and trailer nodes 5. Single-linked list Question 2 One of the statements is correct for stacks and queues 1. Both data structures...
JAVA *** All data structures, including array operations, queues, stacks, linked lists, trees, etc need to...
JAVA *** All data structures, including array operations, queues, stacks, linked lists, trees, etc need to be implemented by you. Write a menu driven program that implements the following Binary Search Tree Operations FIND (item) INSERT (item) DELETE (item) DELETE_TREE (delete all nodes - be careful with the traversal!)
java programing Q: Given the following class: public class Student { private String firstName; private String...
java programing Q: Given the following class: public class Student { private String firstName; private String lastName; private int age; private University university; public Student(String firstName, String lastName, int age, University university) { this.firstName = fisrtName; this.lastName = lastName; this.age = age; this.university = university; } public String getFirstName(){ return firstName; } public String getLastName(){ return lastName; } public int getAge(){ return age; } public University getUniversity(){ return university; } public String toString() { return "\nFirst name:" + firstName +...
C++ language We are given a Queue data structure that supports standard operations like Enqueue() and...
C++ language We are given a Queue data structure that supports standard operations like Enqueue() and Dequeue(): Enqueue(element): add a new element at the tail of the queue; Dequeue(): delete the element at the head of the queue. Show how to implement a stack using two queues. Analyze the running time of the stack operations: Push and Pop.
Create a PowersTable application that displays a table of of powers. ( Java Programing )
Create a PowersTable application that displays a table of of powers. ( Java Programing )
Show how to implement three stacks in one array (in Java)
Show how to implement three stacks in one array (in Java)
Write a java class for a Priority Queue. Use an arraylist, and include enque, deque, and...
Write a java class for a Priority Queue. Use an arraylist, and include enque, deque, and a method to get all the values of the queue. (This is not writing a file implementing the java class PriorityQueue, but rather you are writing a program that is a priority queue).
(In Java) Implement a Deque in which addFirst(), addLast(), removeFirst(), removeLast(), and getMin() are all in...
(In Java) Implement a Deque in which addFirst(), addLast(), removeFirst(), removeLast(), and getMin() are all in O(1) (amortized). The getMin() method is supposed to find the minimum value in the deque and update after ever add/remove. I tried implementing this with a Deque and LinkedList but wasn't successful, you do not need to use either. Must use the comparator and iterator. The goal is to be as fast as possible, so this includes avoiding any operations that aren't O(1) as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT