1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KengaRu [80]
4 years ago
9

Consider designing a program where you need to store information about every student ASU. You need to be able to quickly determi

ne which students are graduating this semester. Would you use an array or linked list? Analyze the problem, design a choice, and justify the choice
Computers and Technology
1 answer:
gulaghasi [49]4 years ago
6 0

Answer:

Check the explanation

Explanation:

Both Arrays and Linked List can be used to store linear data of similar types, but they both have some advantages and disadvantages over each other. To store information about every student we can use an array

Reason:

In the array the elements belong to indexes, i.e., if you want to get into the fourth element you have to write the variable name with its index or location within the square bracket.

In a linked list though, you have to start from the head and work your way through until you get to the fourth element.

Accessing an element in an array is fast, while Linked list takes linear time, so it is quite a bit slower.

Example: store the data of students and have faster access and this program in example also do sorting

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

// struct person with 3 fields

struct Student {

   char* name;

   int id;

   char age;

};

// setting up rules for comparison

// to sort the students based on names

int comparator(const void* p, const void* q)

{

   return strcmp(((struct Student*)p)->name,

                 ((struct Student*)q)->name);

}

// Driver program

int main()

{

   int i = 0, n = 5;

   struct Student arr[n];

   // Get the students data

   arr[0].id = 1;

   arr[0].name = "bd";

   arr[0].age = 12;

   arr[1].id = 2;

   arr[1].name = "ba";

   arr[1].age = 10;

   arr[2].id = 3;

   arr[2].name = "bc";

   arr[2].age = 8;

   arr[3].id = 4;

   arr[3].name = "aaz";

   arr[3].age = 9;

   arr[4].id = 5;

   arr[4].name = "az";

   arr[4].age = 10;

   // Print the Unsorted Structure

   printf("Unsorted Student Records:\n");

   for (i = 0; i < n; i++) {

       printf("Id = %d, Name = %s, Age = %d \n",

              arr[i].id, arr[i].name, arr[i].age);

   }

   // Sort the structure

   // based on the specified comparator

   qsort(arr, n, sizeof(struct Student), comparator);

   // Print the Sorted Structure

   printf("\n\nStudent Records sorted by Name:\n");

   for (i = 0; i < n; i++) {

       printf("Id = %d, Name = %s, Age = %d \n",

              arr[i].id, arr[i].name, arr[i].age);

   }

   return 0;

}

Output:

Unsorted Student Records: Id = 1, Name = bd, Age = 12 Id = 2, Name = ba, Age = 10 Id = 3, Name = bc, Age = 8 Id = 4, Name = aaz, Age = 9 Id = 5, Name = az, Age = 10

You might be interested in
Which variable captures the fact that a person is spontaneous or flexible? A. senses B. judgment C. perceptiveness D. feeling E.
Luba_88 [7]

C. Perceptiveness

The definition for Perceptiveness is: good at understanding things or figuring things out


6 0
3 years ago
Read 2 more answers
Multiple Intelligence Theory explains that...
Alex

Answer:

A. We all learn differently (edge 2020)

Explanation:

4 0
3 years ago
Read 2 more answers
You should click ____ in the category list on the number sheet in the format cells dialog box to select or create a format code.
Mademuasel [1]
Hello <span>Ghaile561</span><span>



Answer: You should click custom in the category list on the number sheet in the format cells dialog box to select or create a format code.


Hope this helps
-Chris</span>
3 0
4 years ago
What is a variable? Why is it helpful in programming?
Komok [63]

Answer:

Variables can represent numeric values, characters, character strings, or memory addresses. Variables play an important role in computer programming because they enable programmers to write flexible programs. Rather than entering data directly into a program, a programmer can use variables to represent the data.

Explanation:

3 0
3 years ago
In the event of a network attack or intrusion, a _____ lists the tasks that must be performed by the organization to restore dam
dexar [7]

Answer:

The answer is "Recovery Plan for Disasters".

Explanation:

In the given statement, some of the information is missing, which can be described as follows:

A) systems engineering plan

B) security compliance plan

C) risk assessment plan

D) Recovery Plan for Disasters

It is a set of guidelines for the execution of a recovery process, it provides the restoration and safety to the system for the organization in the event of a disaster. It defined as "a detailed summary of the appropriate acts to be carried out before, during and after a disaster", and incorrect choices were explained as follows:

  • In option A, It is used to design and analyze complex systems.
  • In option B, It provides frameworks for the corporate evaluation process.
  • In option C, It is used to identify the problems.
6 0
4 years ago
Other questions:
  • Which of the following answers refers to a system containing mappings of domain names to various types of data, such as for exam
    6·1 answer
  • You want to centrally back up the files users store in the Documents folder in their user profiles, but you don’t want users to
    7·1 answer
  • I need an answer and fast What happens if a sequence is out of order?
    5·2 answers
  • Which question is MOST important for an office to consider when upgrading to new software
    5·1 answer
  • Question 4 (Worth 5 points)
    14·2 answers
  • Energía de movimiento de los átomos o moléculas
    11·1 answer
  • Buying the newest phone as soon as it is released when your current phone works perfectly is not a good idea for all but which o
    10·2 answers
  • The physical parts of a computer are called application software.
    9·2 answers
  • If you’d like to have multiple italicized words in your document, how would you change the font of each of these words
    13·1 answer
  • A designer wraps up a final prototype of a language learning app in Adobe XD, and wants to share their work with the development
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!