Create an abstract data type which simulates operations

Assignment Help Computer Engineering
Reference no: EM132164401

Using C, we just learned about structure so we should contain stdio header not like list.h or something else.

all the functions should be used in main function. Thank you!

For this pre-lab you will create an abstract data type (ADT) which simulates operations associated with the ordinary concept of "a list". Those operations include: creating a list, adding items to the list, asking what the kth item is on the list, asking what item is at the end (tail) of the list, and throwing away (i.e., deleting or freeing) the list.

For now we'll keep things simple and assume that we only need to store floats in our lists. Your ADT will be called "List" so you'll need to use typedef with whatever struct you use/define to store the information you'll need for these operations.

An example of a struct definition that could work is:

struct listnode { int maxSizeOfList, tail; float *array; }
Your typedef should allow a user to define a variable such as: List groceryList;

Below are the interfaces / prototypes you'll need to implement:

1. int createList(List *, int) - This function creates and initializes a List variable. The first argument takes the address of a List variable so that its element values can be initialized by the function.

The second argument is an integer giving the maximum possible size of the list. An array of that size will be allocated and the user is responsible for not adding more items to the list than this array can hold. Of course, because this is an ADT the user doesn't know anything about an array.

S/he just knows that a maximum number of elements must be specified and that the number of items added to the list should not exceed that limit. The return value will be zero if the array cannot be allocated and nonzero otherwise. The user is responsible for checking the return value to determine whether an error occurred.

2. int addItem(float, List *) - This function takes the first argument and makes it the last item, i.e., the value at the end of the List specified by the second argument. Return 0 if there is an error, else 1.

3. float getItem(int, List) - This function returns the value located at the index given by the first argument.

4. int sizeOfList(List) - This function returns the number of items on the list.

5. void deleteList(List *) - This function deletes the memory allocated for the array. After this function is executed the user can call createList using the same List variable to define a new list. (Think about why this function is needed.)

Reference no: EM132164401

Questions Cloud

What would be your prime concerns involving police stress : Define Stress. Distinguish between positive and negative stress, describe a police department program that can be implemented to reduce stress.
Terms of the variables of the particular study : Explain what a Type I and Type II error would be in this study. State the answer in terms of the variables of the particular study.
How may have the given case turned out : Complete a timeline outlining important people, ideas, and events in the forensic science profession which have influenced the criminal justice system.
Females with vitamin d deficiency : Assuming that the population variances are unequal, you need to test the claim that infertile females have lower AMH levels
Create an abstract data type which simulates operations : For this pre-lab you will create an abstract data type (ADT) which simulates operations associated with the ordinary concept of "a list".
Pretreatment and posttreatment kps scores : The sample standard deviation of the differences between the pretreatment and posttreatment KPS scores is 10.787. Using a 0.05 significance level
How does stress affect officers : Law enforcement officers face all types of stress during their daily activities. How does stress affect officers? After watching officer stress videos.
Write appropriate accessor and mutator functions : A default constructor that assigns empty strings ("") to the name, address, and phone member variables, and 0 to the age member variable.
Discuss about the boolean-logic operators : This is a pretty easy homework assignment but it just needs to be a program with defined funfuctions that includes boolean-logic operators.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd