(5/5)

Hire Me
(/5)

Hire Me
(5/5)

Hire Me
(5/5)

Hire Me

# For each of your solutions please provide a short explanation as to why you believe your solution works properly

INSTRUCTIONS TO CANDIDATES

data structures and algorithms:#

For each of your solutions please provide a short explanation as to why you believe your solution works properly. This is not formally required, so I will not reduce marks if you choose not to provide any explanations. However, in case the explanations are provided, my feedback will be more meaningful as I will be able to see your line of thought.

1 Most frequently occurring number:

Design an O(n) algorithm whose input is a sorted array A of integer numbers. The program should print the most frequent element of A. For example, in the array A = [1,2,2,5,7,7,7,8], 1 occurs once, 2 occurs twice, 5 occurs once, 7 occurs three times,and 8 occurs once. Hence, the most frequently occurring element is 7. If there are two or more most frequently occurring elements, the algorithm can be print anyone of them (e.g. the ﬁrst one).

Solution to Question 1

2 Number of distinct elements in a sorted array

Design an O(n) algorithm whose input is a sorted array A of integer numbers. The program should print the number of distinct elements of A. For example, in the array A = [1,2,2,5,7,7,7,8], as in the previous section, the number of distinct elements is 5 which are 1,2,5,7,8.

Solution to Question 2

3 Number of distinct elements in an arbitrary array

Design an O(n2) algorithm whose input is an array A of integer numbers (not necessarily sorted). The program should print the number of distinct elements of A

Solution to Question 3

4 Three distinct elements of a sorted array

Design an O(logn) algorithm whose input is a sorted array A of integer numbers. The algorithm should print YES if A contains at least 3 distinct numbers and NO otherwise. Hint: Compare the ﬁrst and the last elements and then use binary search.

## Related Questions

##### . The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

##### . Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

##### . The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

##### . Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

##### . The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme

Get Free Quote!

316 Experts Online