Consider the array A[1..7] = {2, 20, 10, -5, -15, 25, -10}. Running the PARTITION procedure of QuickSort (as described in class and the notes) on this list, with the first element as pivot (2 in this case) produces the following lists: (a) A[1..3] = {-15, -10, -5} and A[4..7] = {10, 20, 25, 2} (b) A[1..3] = {-10, -15, -5} and A[4..7] = {20, 10, 25, 2} (c) A[1..3] = {-10, -15, -5} and A[4..7] = {10, 20, 25, 2}
Q: Implement a shellsort variant where the increment sequence is stored in an array rather than being…
A: void shellSort(int arr[], int n, int gapSequence[], int gapSequenceSize) { int i, j, temp, gap;…
Q: LISTING 7.10 BinarySearch.cpp int binarySearch(const int list[], int key, int listSize) 2 { 1 3 int…
A: Binary Search:- Search a sorted array by repeatedly dividing the search interval in half. Begin with…
Q: Implement the three self-organizing list heuristics: Count – Whenever a record is accessed it may…
A: Answer: main.cpp#include <iostream>#include <string>#include <fstream>#include…
Q: 1. Implement a List using array: a. Implement ArrayList class of ListADT interface which will define…
A: AS PER BARTLEBY GUIDELINE I HAVE ANSWERED ONLY FIRST THREE QUESTION package jss2; import…
Q: The list ADT interface and its implementation remove the need for the original list interface and…
A: Study the properties of the data abstraction and develop a list of operations that it should…
Q: PROBLEM STATEMENT: In this problem you will need to update a specific array element. You are…
A: Required: PROBLEM STATEMENT: In this problem you will need to update a specific array element. You…
Q: True or False For each statement below, indicate whether you think it is True or False. provide a…
A:
Q: Reverse a singly linked list by changing the pointers of the nodes. The data represented by the list…
A: In this question we have to understand and write a code for reversing singly linked list for the…
Q: Write a Java class myLinkedList to simulate a singly linked list using arrays as the underlying…
A: The program comprises of 2 classes MyLinkedList and a Main class called the Driver class. An array…
Q: Please develop well-documented pseudo code that finds all consecutive similar elements of a given…
A: The length of an algorithm's input and how long it takes to execute are the two factors that…
Q: S is an initially empty circular array-based STACK of size 8, where top has a value of -1 at…
A: A stack is an abstract data type used in computer science that acts as a collection of components…
Q: 1) Implement and test DoublyLinked List class. Please put both Node and DoublyLinkedList class…
A: Python Programming which refers to the one which it is a high-level, general-purpose programming…
Q: Using arrays or ArrayList in java language Write the method named mesh. * * Start with two…
A: Define package java.utils.Arrays which is used for working with Arrays in java Define main class…
Q: using arrays or Arraylist in Java language Write the method filterBySize(). * * Given an ArrayList…
A: CODE: //Driver code public class Main { public static void main(String[] args) { String []arr= {"a",…
Q: Given a list (44, 80, 96, 33, 15, 42, 73, 99, 91, 77) and a gap array of (5, 4, 1): What is the list…
A: Answer: We will do nothing but insertion sort for the given interval so we will see in the more…
Q: Heapsort has heapified an array to: 76 62 40 32 30 and is about to start the second for loop. What…
A: Here is the solution with explanation:-
Q: Heapsort has heapified an array to: 89 63 50 37 26 and is about to start the second for loop. What…
A: Iterations of the heap sort :
Q: What is the best way to implement a stack or a queue so that it can hold an arbitrary number of…
A: The best way to implement a stack or a queue so that it can hold an arbitrary number of elements:
Q: sum: This method takes a list List L and returns the total sum of the elements in that list. If the…
A: Step 1: Initialize a list of integers.Step 2: Add three integers to the list.Step 3: Create an int…
Step by step
Solved in 3 steps
- java In this assignment you will swap a position in an array list with another. swap() gets 3 arguments, an Arraylist, a position, and another position to swap with. Example swap(["one","two","three"],0,2) returns:["three","two","one"] public static ArrayList<String> swap(ArrayList<String> list,int pos1,int pos2) public static void main(String[] args) { Scanner in = new Scanner(System.in); int size = in.nextInt(); int pos1 = in.nextInt(); int pos2 = in.nextInt(); ArrayList<String> list = new ArrayList<>(); for(int i=0; i < size; i++) { list.add(in.next()); } System.out.println(swap(list, pos1, pos2)); } }I have implemented a stack using arrays. The array is 5 elements long and is called examstack. The contents are: examstack[0] = 36 examstack[1] = 49 examstack[2] = 7 examstack[3] = 67 examstack[4] = 9 If I did a Pop what would be returned? 9 or 36 09 07 O 67 O 9 or 67 36 or 49 O 36 49joinList(n) (2 pts) Takes an integer number n. This functions returns the list [1,2,...,n,n,...2,1] for every n>0. Preconditions: While the function will receive integer values, you should not make any assumptions about the value of n. Input An integer value Output list Starting at 1 moving upwards, a list with the sequence 1 to n, followed the sequence that starts at n moving downwards to 1 None Argument do not satisfy the conditions of the function Example: >>> joinList(5) [1, 2, 3, 4, 5, 5, 4, 3, 2, 1] >>> joinList(1) [1, 1] >>> joinlist(-3) is None True
- This program will use an array implementation of a linked list to keep an ascending sorted list of numbers. The input data consists of two fields: a single character and an integer value. The single character gets interpreted as one of the following: A - represents a value that is to be added to the linked listD - represents a value to be deleted from the linked listP - indicates that all values are to be printed in ascending order The character is only used to determine which process is to be executed; it should not be printed, entered into the linked list, or processed in any way. The main program should be mainly function calls. Process input data until end of file. All output should be sent to an output file and be appropriately formatted and labeled. Keep a running log of everything that is going on in the processing. Input file: A 54A -17A 32 A 81 A -30 A 18 P A 41 A 93 A 65 A 80 A 104 A -20 D 81 D 54 D -30 A 79 A 63 A 77 A –33 D 104 D -20 D 80 D 32 PCreate a list – l1 with element 1,2,3,4,5. Convert this list into an array name ar. What is the dimension of this array – one dimension, 2 dimension or multidimension What is the datatype of elements of array. Print the second element of an array. Create a nested list – l2 with three lists. Elements of each lists are – [1,2,3];[4,5,6];[7,8,9] Convert this list into an array ar2. What is the dimension of this array. Observe the parenthesis. Print 8 from this array. Without using list, create an array ar3, which has the even number from 2 -10. Use the np.arange(start, end, skip). Run the following code and observe the output.You will create two programs. The first one will use the data structure Stack and the other program will use the data structure Queue. Keep in mind that you should already know from your video and free textbook that Java uses a LinkedList integration for Queue. Stack Program Create a deck of cards using an array (Array size 15). Each card is an object. So you will have to create a Card class that has a value (1 - 10, Jack, Queen, King, Ace) and suit (clubs, diamonds, heart, spade). You will create a stack and randomly pick a card from the deck to put be pushed onto the stack. You will repeat this 5 times. Then you will take cards off the top of the stack (pop) and reveal the values of the cards in the output. As a challenge, you may have the user guess the value and suit of the card at the bottom of the stack. Queue Program There is a new concert coming to town. This concert is popular and has a long line. The line uses the data structure Queue. The people in the line are objects…