Question

Name three types of data structures. How is an element in an array different from an...

  1. Name three types of data structures.
  2. How is an element in an array different from an element in a record?
  3. How is an element in an array different from an element in a linked list?
  4. Why should we use indexes rather than subscripts to identify array elements?
  5. How are the elements of an array stored in memory?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

What is a Data Structure?

Data Structure, the name itself suggests us that organizing data in a particular structure. In other words Data Structure is used to store or organize data in a specified fashion. For example Array is one of the Data Structures which is used to store similar type of data (In an Integer Array we can store only Integers not other data types like Strings etc.) in a continuous memory locations (First we need to specify size of an Array, based on Array size required memory will be allocated to that array in the RAM and as and when we put data in that Array based on index data will be stored in the one of the indexes in allocated memory).

Name three types of data structures.

We have so many Data Structures.

All the Data Structures are categorized in two categories

1. Linear

2. Non-linear

1. Linear Data Structures

As I mentioned earlier there are so many Data Structures let's list a few here

Array

Stack

Queue

Linked List

2. Non-Linear Data Structures

Let's list a few Non-Linear Data Structures here

Tree

Graph

How is an element in an array different from an element in a record?

The difference between Array and Record is, Array stores data of same type(only int or only string etc.) in contiguous memory locations where as Record is also a Data Structure which stores data of multiple data types (you can store int, string, float etc. in single record) in fields. A record is used to stored data of different data types. You can consider an example as Database record. If you take Student table, in single record we store name of type string, we store age of type int, we stored data of birth of type date etc. Basically both the Data Structures are different each other.

How is an element in an array different from an element in a linked list?

The main difference between Array and Linked List is, in the case of Array data will be stored in contiguous memory locations where as in the case of Linked List data will be stored where ever memory is available to store an element.

For example if we want to Store 10 elements in the memory by using Array Data Structure then we need contiguous memory if we don't have we can't store using Array. For Linked List we don't need to have contiguous memory location but If we have memory at 10 different locations to hold our 10 elements that is fine, we can use Lined List to store 10 elements at different memory locations but we can't use Array.

Coming to our question, as discussed above there is a lot of difference between Array and Linked List in terms of storing data (element) and organizing data (element).

Why should we use indexes rather than subscripts to identify array elements?

First of all both index and subscript are used to access an element from an Array.

Subscript actually represents position of the element(2nd element or 3rd element etc.) with in the array where as index represents displacement value from the beginning of the array.

For example to access an element at position 3 we write something like below

numbers[3]

here 3 is the subscript, which says want to access 3rd element.

In the case of index, numbers[3]

here 3 is subscript but internally it uses index approach so it calculates displacement value from the beginning of the array to fetch an element at the position 3.

displacement value = array starting address + subscript * size of data type (This formula gives you at which address location our element exist)

How are the elements of an array stored in memory?

Elements in an Array will be stored in a continuous memory locations. What does that mean?

Let's understand.

I want to create an Array with size 10. Which means I want to create an Array which will store 10 elements of type Integer.

Let me create example Array in Java (you don't need to have knowledge on java to understand below statement. If you don't understand let's not focus on below statement but understand that we want to create an Array with size 10 elements of type int)

int[] numbers = new int[10];

The above java statement says to the java program executor that create an Array with size 10 and type of the data that stores is Integers.

In Java to store int data type it takes 4 bytes of memory.

Let's consider our memory starting address is 2000. Each memory location will have an address.

20 22 27 18 15 17 10 15 11 10
2000 2004 2008 2012 2016 2020 2024 2028 2032 2036
0 1 2 3 4 5 6 7 8 9

First row represents our Array with data.

Second row represents our Array addresses for each index.

Third row represents our Array indexes.

When you ask array give me data which is in index five. Array index starts with 0.

numbers[5]

address of 5th location = starting address + index * size of data type (in our case int 4 bytes) = 2000 + 5 * 4 = 2020

numbers[5] will return us 17 that is the data which is in the array index 5.

You may have a question about starting address that how do I know starting address, you don't need to worry about it that will be taken care by the program executor. I am explaining here how internals work.

Add a comment
Know the answer?
Add Answer to:
Name three types of data structures. How is an element in an array different from an...
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
  • Data types and structures Pascal allows the use of enumerated types as index types. For example,...

    Data types and structures Pascal allows the use of enumerated types as index types. For example, if we define the enumerated type GreatLakes to have the values Erie, Ontario, Huron, Michigan, and Superior (ordered here by increasing volume of water), then we can define: type GreatLakes = (Erie, Ontario, Huron, Michigan, Superior); area: array [ GreatLakes ] of integer, elevation: array [ GreatLakes ] of real; and give them values area := ( 9910, 7340, 23000, 22300, 31700 ); elevation...

  • Identify the basic elements in a C++ program; briefly describe each element Describe the data types...

    Identify the basic elements in a C++ program; briefly describe each element Describe the data types you may use in C++, and their relationship to memory allocation?

  • ch 6 ex 14 lists plus, c++ plus data structures, linked list understanding Problem: Use the...

    ch 6 ex 14 lists plus, c++ plus data structures, linked list understanding Problem: Use the linked lists contained in the array pictures in figure 6.19 (see pics) to amswer the following questions : please show some explanation / work so that i can grasp and retain this information Thank you so much for your time! 14. Use the linked lists contained in the array pictured in Figure 6.19 to answer the following questions: a. What elements are in the...

  • Creating linked list data structure Overview The purpose of this assignment is for you to write...

    Creating linked list data structure Overview The purpose of this assignment is for you to write a data structure called a Linked List, which utilizes templates (similar to Java’s generics), in order to store any type of data. In addition, the nature of a Linked List will give you some experience dealing with non-contiguous memory organization. This will also give you more experience using pointers and memory management. Pointers, memory allocation, and understand how data is stored in memory will...

  • i need the solution for matlab creat arry in matlab Eacih atomic mumber (indicating the number of protons in its ow how a structure can be created to represent these three pieces of Chemical el...

    i need the solution for matlab creat arry in matlab Eacih atomic mumber (indicating the number of protons in its ow how a structure can be created to represent these three pieces of Chemical elements can be described by their name element also has an nucleus). 05.H y their name or their symbol. Ea information for an element. Use the italićs above Give an example for an element of your choice for the fietd names 2. Repeat th e previous...

  • Please use Java only: Background: Java contains several different types of interfaces used to organize collections...

    Please use Java only: Background: Java contains several different types of interfaces used to organize collections of items. You may already be familiar with the List interface, which is implemented by classes such as the ArrayList. A List represents a collection of elements from which elements can be stored or retreived, in which elements are ordered and can be retrieved by index. A List extends from a Collection, which represents a collection of elements but which may or may not...

  • Iterating over a 2D array If we want to visit or process every element of a...

    Iterating over a 2D array If we want to visit or process every element of a 2D array, we need a nested for loop to do it. Generally, when you iterate over a 2D array, you want to do it in row major order, because this is more memory efficient. The reason why is that adjacent elements in a row are stored contiguously (one after another) in memory. Another reason, for an English speaker, is that this is the same...

  • Class DemoArray: 1. Create an array of type String , name it words, and initialize it...

    Class DemoArray: 1. Create an array of type String , name it words, and initialize it with the following words: one, two, three, four, five, four, three, two, one 2. Use a method of class Arrays to print the array. Make sure to use a label 3. At this point we are going to fix the misspelled word three. Use a loop to access the elements of the array. One by one check whether the current element happens to be...

  • 8.9 Coding lab #5: create a dynamic array ADT and a singly linked list ADT. Honor Code...

    8.9 Coding lab #5: create a dynamic array ADT and a singly linked list ADT. Honor Code Your answers to this homework must be your own work.You are not allowed to share your solutions.You may not engage in any other activities that will dishonestly improve your results or dishonestly improve or damage the results of others. Plagiarism Plagiarism is when you copy words, ideas, or any other materials from another source without giving credit. Plagiarism is unacceptable in any academic environment....

  • Short answer in your own word: 1. Describe the role of a “Back-End” computer engineer in...

    Short answer in your own word: 1. Describe the role of a “Back-End” computer engineer in creating software. Give examples of decisions back end engineers make. Use the relationship between long-term and short-term memory as context for decision examples. 2. Identify Stack or Heap storage in RAM. a) Hash Map with static array as underlying storage b) Doubly Linked LIst - Stack Implementation c) Binary Search Tree with 10,000 Nodes d) Static Array - Stack Implementation c) Doubly Linked List...

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