Write down the algorithm to insert an item

Assignment Help Data Structure & Algorithms
Reference no: EM133654

QUESTION 1

(a) (i) What is a pointer? Illustrate with an example

(ii) Give two advantages of the use of pointers over arrays

(b) (i) Declare an array called vowel which contains the elements ‘a', ‘e', ‘i', ‘o', and ‘u'. (ii) Declare a pointer ptr of type char which points to the array vowel

(iii) Write down a loop to display the actual address and content of pointer ptr when it points to the different elements of array vowel

(c) (i) Declare an integer array of size ten

(ii) Write down appropriate statements to request the user to enter ten integer numbers into the array created in c (i) above

(iii) Write down appropriate statements which will search the number zero inside the array using linear search algorithm. Include an output statement to print out the number of elements in the array before the zero if it is found

QUESTION 2

(a) (i) How does a structure differ from a union?

(ii) How can the size of a structure be determined? In what units is the size reported?

(iii) How is a structure-type pointer variable declared? To what does this type of variable point?

(b) What is a self-referential structure? Illustrate with a suitable example

(c) (i) Define a structure that contains the following members: 1) dvd_name, 2) quantity and 3) cost Include a user-defined data-type movie within the definition

(ii) Now define another structure that contains the following members: 1) batch_id and 2) film of type movie defined above Include the user-defined data type dvd within the definition

(iii) Declare a variable v1 to be a structure variable of type dvd. Write an expression for each member and submember of v1

(iv) Declare a variable v2 to be a structure variable of type dvd and initialize v2 with the following values: dvd_name: Red Dragon quantity: 4 cost: 100 batch_id: 2101

(d) (i) What is the primary advantage to using a data file?

(ii) Describe the different ways in which a data file can be categorized

(iii) What is the purpose of a buffer area when working with data-files?

(iv) How is the buffer area defined?

(v) What is meant by opening a data file?

QUESTION 3

(a) Using an appropriate example, explain what is a recursive function?

(b) Write a small program using a function called cumulative that accepts as parameter n and returns the sum of integers between 1 and n inclusive

(c) A student was asked to write a program in C to swap two numbers using a function and pointers. However the student failed to solve the work and the program was left incomplete as shown below. Use the code extract below to complete the program using function and pointers

#include<stdio.h>

void swap(int *, int *);

void main { int a = 23, b = 32; ... ... }

void swap(int *x, int *y) { int temp; .... ..... }

QUESTION 4

(a) Write down the sample code to create a 'Linked List' and allocate storage space for a node

(b) Write down the algorithm to insert an item

(i) At the beginning of a linked list

(ii) In the middle of a linked list

(iii) At the end of a linked list

(c) Write down the sample code to declare a stack

(d) Explain how the binary tree below can be traversed in each of the following ways-

(i) preorder

(ii) inorder

(iii) postorder

361_binary tree.png

Reference no: EM133654

Questions Cloud

Write down an energy transformation equation : Write down an energy transformation equation
Doxey''s irridex model : Tourism Area Life Cycle, Tour operators nowadays play a very significant role in creating the images of destinations, imensions of sustainable community tourism development., Tourism has become a development tool for many rural and more isolated are..
Determine the eccentricity of the orbit of uranus : Determine the eccentricity of the orbit of Uranus
Determine the cost of goods sold and ending inventory : Determine the cost of goods sold and ending inventory on June 30, considering that Handy uses: Determine the depreciation expense Tastee would identify on this equipment for each of the five years, assuming:
Write down the algorithm to insert an item : Write down the sample code to create a Linked List and allocate storage space for a node Write down the algorithm to insert an item At the beginning of a linked list
Evaluate the production cost : Whole a production cost report for the Motor Department of Sun Appliance for March. Leave no cells blank - be certain to enter "0" wherever needed.
What is an angular speed about the center of mass : What is an angular speed about the center of mass
Evaluate net present value of this investment opportunity : Evaluate the net present value of this investment opportunity. Determine the internal rate of return of this investment opportunity.
Explain the spacing between allowed vibrational energy level : Explain the spacing between allowed vibrational energy levels

Reviews

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