Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am doing a programming assignment for my data structres and algorithms course,

ID: 3803970 • Letter: I

Question

I am doing a programming assignment for my data structres and algorithms course, and I am a little lost on this portion of the assigment. If anyone could give an explanation on what I am supposed to do here it would be greatly appreciated. I don't need you to write code, just an explanation.

You need to define the following data types

• ELEMENT is a data type that contains a field named key, which is of type int. In later assignments, you will have to add on other fields to ELEMENT, without having to change the functions. Note that ELEMENT should not be of type int.

• HEAP is a data type that contains three fields named capacity (of type int), size (of type int), and H (an array of type ELEMENT with index ranging from 0 to capacity).

Explanation / Answer

You are doing assignment for data structures right. So you may have come across the things like stack, queue or linked list.

See, here you are told to define the data type on your own. Plus, they are not system in-built, They will be user defined for sure. So, you can implement them by either using concept of Class and objects or you can do the same thing using structure. Using structure is feasible here because you have not mentioned the programming language, it will be either C or C++. And C language does not have something like Class and Object so use structure here and you can use it for both the languages.

You said you do not want the code for this so I will tell you using example of stack instead. That seems good you want to implement it by your own.

Stack is a data structure having a array of elements say here int and a variable called top which points to the top element in the stack. This is the information given. Now I want to define this datatype as follows...

To define your own datatype, use typedef and to combine more than one in-built or derived datatype (like int and float and array something like this) use a structure. So, this datatype can be defined as:

typedef struct

{

int elements[100];

int top;

}stack;

So, here the stack datatype contains 2 things: elements is an array of int and an int variable. This how using typedef struct I created the data type and declared a structure variable 'stack' also to use it in the program further.

This is the way you are asked to define the 2 datatypes. Declare them using typedef struct and inside them, write the appropriate elements as given requirements. This is the task you need to complete.

Not writing the definitions by myself as you said. If you want it, or if there is any query, do comment. Thank you. :)