Question

Knowing when to apply a data structure for a given business problem is an important skill for developers to know. Resea...

Knowing when to apply a data structure for a given business problem is an important skill for developers to know.


Research the following .NET data structures:

    List
    ArrayList
    LinkedList


Discuss examples of business problems that could be solved using each of the data structures.

Knowing how to sort data in an array and knowing which sorting algorithm to use makes implementing sorting easier.


Discuss different ways to sort an array in C#. What do you see as the advantages and disadvantages of each type of sorting algorithm?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ArrayList, is a dynamic array. What that means is an ArrayList can have any amount of objects and of any type. This data structure was designed to simplify the processes of adding new elements into an array. Under the hood, an ArrayList is an array whose size is doubled every time it runs out of space. Doubling the size of the internal array is a very effective strategy that reduces the amount of element-copying in the long run. We won't get into the proof of that here. The data structure is very simple to use:

ArrayList myArrayList = new ArrayList();
myArrayList.Add(56);
myArrayList.Add("String");
myArrayList.Add(new Form());

----------------------------------------------------------------------------------------------

List is the generic version of ArrayList, which means that it behaves exactly the same way, but within a specified type. So for example, a List of integers would work as follows:

List<int> intList = new List<int>();
intList.Add(45);
intList.Add(34);

----------------------------------------------------------------------------------------------LinkedList is a series of objects which instead of having their references indexed (like an Array), stay together by linking to each other, in Nodes.

A LinkedList Node has basically three values: the Object's Value, a reference to the Next node, and a reference to the Previous Node.

What is the point of such C# data structure? Well, adding values to the middle of the list is much faster compared to any other Array type of data structure. It also keeps memory costs down to a minimum. Lists on the other hand use extra space to make future insertions as fast as possible.

LinkedList<int> list = new LinkedList<int>();
list.AddLast(6);

Retrieving a value is not as straight forward:

list.First.Value 
or
list.Last.Value

Since inserting and removing elements is done by updating a couple references, they can be done in constant time. The tradeoff is that accessing elements is no longer a constant time operation. In an array, with a given index an element can be instantly accessed. With a linked list, the references between nodes need to be followed until the desired element is found.

----------------------------------------------------------------------------------------------

There are various sorting Algorithms:

  • Method 1: Using Array.Sort() and Array.Reverse() Method
    First, sort the array using Array.Sort() method which sorts an array ascending order then, reverse it using Array.Reverse() method.
  • Method 2: Using CompareTo() Method
    You can also sort an array in decreasing order by using CompareTo() method.
  • Method 3: Using delegate
    Here, first Sort() the delegate using an anonymous method.
  • Method 4: Using Iterative way. Sort an array without using any inbuilt function by iterative way.

  • Method 5: Using LINQ descending
    LINQ stands for Language Integrated Query. It is a uniform query syntax which is used to retrieve and save the data from the different sources. Here, OrderByDescending sorting method is used for descending order sorting. The LINQ returns IOrderedIEnumerable, which is converted to Array using ToArray() method.
Add a comment
Know the answer?
Add Answer to:
Knowing when to apply a data structure for a given business problem is an important skill for developers to know. Resea...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • STEP 1: In your own words define problem employees and the categories they may fall into....

    STEP 1: In your own words define problem employees and the categories they may fall into. For the second or last paragraph provide your opinion on which employee type is the most difficult. DEFINITION : I think that "problem employees" are employees that either directly or indirectly hinder the organization's mission or vision, and break down into roughly four categories. In general, problem employees can be classified into two broad categories - employees creating problems for the organization and employees...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

  • First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below...

    First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below Include each of the following in your answer (if applicable – explain in a paragraph) Research problem: what do you want to solve using Delphi? Sample: who will participate and why? (answer in 5 -10 sentences) Round one questionnaire: include 5 hypothetical questions you would like to ask Discuss: what are possible outcomes of the findings from your study? Hint: this is the conclusion....

  • ABC International: Solving the Rural Barrier

         Compensation sessionABC International:   Solving the Rural BarrierSource: Thunderbird School of Global Management, A unit of the Arizona State University Knowledge Enterprise. 2015. This case was prepared by Erin Bell under the guidance and supervision of Dr. Amanda Bullough, and revised and updated by Drew Helm for the purpose of classroom discussion only, and not to indicate either effective or ineffective managementSiham sat with her family and childhood friend, Leila, in their rural village of Qabatiya, Palestine. Leila had recently returned from...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

  • Below is the information: It is important to understand the different leadership styles employed by nursing...

    Below is the information: It is important to understand the different leadership styles employed by nursing leaders in healthcare organizations and to understand their significance on nursing practice and patient outcomes, for better or for worse. Objective: Read the articles from Nursing Standard (PDF) and Bradley University (PDF). In -250 words, formulate an opinion on the following: 1. Reflect on an occasion where you experienced ineffective leadership (doesn't have to be in the hospital). What behaviors did they display? What...

  • What an Executive Summary Is An executive summary is a specific type of document that does...

    What an Executive Summary Is An executive summary is a specific type of document that does two things: it summarizes a research article, and it offers recommendations as to how information from the article can be used. Some long reports can contain an executive summary section, as indicated in the Pearson handbook. Write a 2 pahe Executive Summary In business contexts, an executive summary is always written for a specific purpose: to explain the information in the article to a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT