COMP1000 UNIX & C Programming Assignment

Assignment Help Data Structure & Algorithms
Reference no: EM132495613

COMP1000 - UNIX & C Programming - Curtin University

Worksheet: Structs

The objectives of this practical are to understand how to:
• design and use structs; and
• implement a linked list using structs.

Pre-lab Exercises

Part 1. Creating Structs

Declare (with typedef) suitable structs to hold the following information:
(a) A date.
(b) A set of coordinates in 3D space.
(c) A postal address.
(d) The details of a practical class at Curtin.
(e) The details of all practicals for a unit.

2. Dynamic Allocation and Deallocation
Write C code to dynamically allocate and then deallocate the following:
(a) The date struct from Question 1a.
(b) An array of 25 coordinate structs from Question 1b.
(c) A struct called Info that contains a char* field called name, intended to store names up to 99 characters.
(d) An array of 25 Info structs.
(e) The following struct, so that it keeps track of an array of 25 Info structs:

3. Expressions with Pointers, Arrays and Structs
The following expressions use a combination of pointers, arrays and structs. In each case, describe (i) what "var" is by itself and (ii) what the overall expression is accessing.
(a) var.b
(b) var->b


(c)
(d)
(e)
(f)
(g)
(h)
(i)

var[i].b
var[i]->b
var->b[i] var[i]->b[j]
*(var[i]->b) var->b->c var.b[i][j].c

4. Linked List Structs
Design a set of structs to hold a linked list, where:
• The values to be stored in the list are structs called FruitBat.
• The size of the list must be instantly accessible.
• The last element of the list must be instantly accessible.
How does the last point complicate the insertion of a new element?

5. Miscellaneous Questions
(a) When inserting an element at the start of a linked list, you must (a) point the new node's "next" field to the existing first node, and (b) point "head" to the new node. Why does the order of these operations matter?
(b) Can an element belong to more than one linked list simultaneously?
(c) Can an element appear more than once in the same linked list?

Practical Exercises
1. Files and Structs
Write a C program to read a file and store the contents in a dynamically-allocated array of structs.
The file contains journal entries, each consisting of a date and a text string. Each entry occupies two lines. The first line of each entry contains the date (in "day/month/year" format) and the second contains the text. The text can be up to 100 characters long, not including the new-line character.
The very first line of the file contains a single integer, indicating the number of journal entries in the file.

You should declare a suitable struct (in a header file), allocate an array just large enough to hold all the entries, and then read each entry into the array.

Part 2. Linked Lists
For this question please ensure that you download the linkedlistTest.c file from Blackboard and use that to test your Linked List
Write a set of C functions in a file called ‘linkedlist.c‘ to manipulate a generic linked list.

The test harness is able to support the main kinds of list implementation aswell. Whether it be single or doubly ended or single or doubly linked (Just need to add a #define at the of the testing file )

You will need to create appropriate structs, and write functions to:
(a) Create an empty linked list.

(b) Insert an element at the start. This function should take (i) a pointer to an existing linked list, and (ii) a pointer to an existing journal entry struct, to be inserted at the start of the list.
(c) Remove an element from the start. This function should take a pointer to an existing linked list, remove the first element from the list and return a pointer to it. (Return NULL instead if the list is empty.)
(d) Insert an element at the end. This function should be similar to your insertStart function, however instead of working with the head of the list its now the tail.

(e) Removing an element from the end. This function should be similar to your removeStart function, however instead of working with the head of the list its now the tail.

(f) Print out the contents of the list.

(g) Free the list.

Part 3. Convert To Linked List
For this question you are to redo Question1 however with 2 differences:
• Remove the first line of the file that contains the number of entries
• Implement it using your LinkedList instead of an Array

Attachment:- Unix and C Programming Worksheet.rar

Reference no: EM132495613

Questions Cloud

Develop appropriate null and alternative hypotheses : Develop appropriate null and alternative hypotheses such that rejection of H0 will support Dr. Smith's argument.
Compute the cash proceeds from bond issues : Compute the cash proceeds from bond issues under the following terms. For each case, indicate whether the bonds Cash proceeds vs Discount or premium
What is the fabs dollar cash outflows : If the spot rate in 90 days is $0.84, what is the FAB's dollar cash outflows, assuming FAB wishes to minimize its cost (please round to a dollar)?
COMP1000 UNIX and C Programming Assignment : COMP1000 UNIX and C Programming Assignment Help and Solution - Curtin University, Australia. Design, code (in C89), test and debug a modified battleships game
COMP1000 UNIX & C Programming Assignment : COMP1000 UNIX & C Programming Assignment help and solution, Curtin University - assessment writing service - Write a C program to read a file and store
Record a lease amortization schedule for the lessor : Record the journal entries on Sahali Air's books to record the lease agreement, to reflect payments received under the lease, and to recognize income
Calculate the value to be assigned to the bonds : The bonds are quoted at 99 ex-rights, and the warrants are quoted at $5 each. Calculate the value to be assigned to the bonds and to the warrants
What kind of lease is to dufferin corp : What kind of lease is this to Dufferin Corp and why? Calculate the present value of the minimum lease payments over the life of the lease. Round to the nearest
How aroma investment in baltic increase aroma net income : During the year, Baltic pays $10,000 in dividends to Aroma and reports $100,000 net income. Aroma's investment in Baltic will increase Aroma's net income by

Reviews

len2495613

4/18/2020 4:04:45 AM

Hello I need help with homework, Practical Exercises,question 2. Linked Lists. I have attached the testing file for the program, also i have attached my answers for question 2. Linked Lists section a) b) and c), i believe my answers are correct, however i want help with e) f) and g). so the over all help is with Practical Exercises,question 2. Linked Lists. writing the functions with comments, please write meaningful comment so i can understand what is going on in the program. Thanks

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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