Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment#6 Linear Data Structure Due Date: Midnight of April 21 (Saturday) Purpose: The purpose of this assignment is to help you: Understand search and sort

Assignment#6 Linear Data Structure

Due Date: Midnight of April 21 (Saturday)

Purpose: The purpose of this assignment is to help you:

Understand search and sort Understand Generic method, Generic interface, Generic class and Hash table

Instructions: Be sure to read the following general instructions carefully:

This assignment should be completed individually by all the students. You are encouraged to demonstrate your solution during lab session, and submit your solution through the dropbox. You must name your submission according to the following rule: studentID(yourlastname)_ASSnumber.zip. e.g., 300123456(smith)_ASS#7.zip

Question 1[10 marks]

Use a concrete example to explain how generic methods can be overloaded [3 marks] Explain following terms [1 mark per term]

ICollection Array IList Load factor Hash-table collision Space/time trade-off in hashing dictionary

Question 2[10 marks]

Linear search algorithm searches each element in an array sequentially. If the search key does not match an element in the array, the algorithm tests each element and, when the end of the array is reached, informs the user that the search key is not present. If the search key is in the array, the algorithm tests each element until it finds one that matches the search key and returns the index of that element.

Write a generic method, Search, that searches an array using linear search algorithm. Method Search should compare the search key with each element in its array parameter until the search key is found or until the end of the array is reached. If the search key is found, return its location in the array; otherwise return -1.

Write a test app that inputs and searches an int array and a double array. Provide buttons that the user can click to randomly generate int and double values. Display the generated values in a TextBox, so the user knows what values they can search for. [Hint: use (T: IComparable) in the where clause for method search so that you can use method CompareTo to compare the search key to the elements in the array]

c# programming

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

1. Explain the 2nd world war. 2. Who is the father of history?

Answered: 1 week ago

Question

7. Determine what feedback is provided to employees.

Answered: 1 week ago