

2. (15 marks) Consider the abstract datatype SEQ whose objects are sequences of elements and whic...
Translate this matlab code to python title('Starting Number vs Number of Elements in Seq') ylabel('Number of Elements in the sequence in the sequence') xlabel('Starting Number') steps = []; vec = 1:25; for i=1:length(vec) s = []; num = i; while true s(length(s)+1) = num; if num == 1 break; elseif mod(num, 2) == 0 num = num/2; else num = (3*num)+1; end end fprintf('%d = ', i) disp(s) fprintf('\n') steps(i) = length(s); end plot(vec, steps)
Data Structure
Java code
Q2 [ 20 pts]. In computer science, a priority queue is an abstract data type which is like a regular queue data structure, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority. If two elements have the same priority, they are served according to the order in which they were enqueued A typical priority queue supports following...
2. Short programming assignment. Implement a bottom-up mergesort that first sorts blocks of M elements using insertion sort. Test your program with large sets of random data and determine what value of M works best. 3. The following refer to linked list mergesort Explain why mergesort is more suitable for linked lists than other sorting methods. a. Explain why mergesort is more suitable for linked lists than other b. Consider a file that is “mostly sorted.” Explain how the principles...
Would someone be able to help me with this please? It has to do with Linked List Arrays, and I'm very confused on what to do. Any help along with steps would be very much appreciated. Cheers! You are hired by a company to implement a singly-linked list that will hold integers, using Java programming language. However, the boss of the company insists that you don’t use any objects or structures in your implementation. You may use only integer arrays...
please be thorough with
explanations. thank you
Question 2 Consider the implementation we made in class for ArrayList, and its extensions you did in the lab. In this question, we will add two more methods to this class: the insert method and the pop method. For this question, please submit the modified ArrayList class. a) Implement the method insert (self, index, val) that inserts val before index (shifting the elements to make room for val). For example, your implementation should...
Plz i want answer these question using list in python
programme.
You are given two sequences of n integers: 21, 22, ...,an and b1,b2, ..., bn Print a sequence of 2n integers created by alternating elements from the given sequences: a1, 61, 42, 62, a3, 63, ..., an, bn. Input The first line contains a positive integer n (1 <n<1000) - the length of the sequences The second line contains n space-separated integers 01, 02, ..., an (-1000 <a; <...
A skip list is a data structure that allows Oflog n) search complexity as well as O(log n)insertion complexity within an ordered sequence of n elements. A skip list is built in layers. Each layer is a linked list. The bottom layer is an ordinary ordered linked list. Each higher layer acts as an "express lane" for the lists below, where an element in layer L appears in layer L+1 (higher layer) with some fixed probability p. A search for...
And the related
algorithms:
(20 points) Consider the following strategy for choosing a pivot element for the Partition subroutine of QuickSort, applied to an array A. .Let n be the number of elements of the array A. If n 24, perform an Insertion Sort of A and return. Otherwise: Choose 2n/2)| elements at random from n; let S be the new list with the chosen elements. Sort the list S using Insertion Sort and use the median m of S...
PART 1 Implement a C++ class for an array representation of a list. The methods must be based upon the pseudocode provided on the CS210 Algorithms below. Use the following declarations as a starting point for your implementation. const int MAX_LENGTH = some application-specific max value; typedef <some data type> DataType; class List { public: methods go here private: int p; int length; DataType a [MAX_LENGTH]; }; Note: Any other variable or constant declarations required would...
Case Study 2 Convection) – 30 Marks Consider an air duct heater consists of electrical heating elements with an aligned arrangement and the longitudinal (5) and transverse pitches (S.) of 5 = 5, = 22 mm. There are 3 rows of elements in the flow direction (N = 3) and 3 elements in each row (N = 3). The atmospheric air at a velocity of V = 10 m/s, and a temperature of. = 15°C enter the duct and flow...