Define the self-referential structures, C/C++ Programming

Assignment Help:

Define the Self-Referential Structures?

It is occasionally desirable to include within a structure one member that is a pointer to the parent structure type. Generally in terms this can be expressed as

struct tag
{
member 1;
member 2;
. . . . .
struct tag *name;
} ;

Where name refers to the name of a pointer variable therefore the structure of type tag will contain a member that points to another structure of type tag. Such structures are called as self-referential structures.

A C program contains the following structure declaration.

struct list_element
{
char item[40];
struct list_element *nextj
} ;

This is a structure of type list_element and the structure encloses two members a 40-element character array, called item, and a pointer to a structure of the same type (that is a pointer to a structure of type list_element), called next. Thus this is a self-referential structure. .

The Self-referential structures are extremely useful in applications that involve linked data structures, such as trees and lists. The fundamental idea of a linked data structure is that each component within the structure includes a pointer indicating where the next component is able to be found. Consequently the relative order of the components can simply be changed simply by altering the pointers. As well individual components can easily be deleted or added again by altering the pointers. As a result, a linked data structure isn't confined to some maximum number of components. Somewhat the data structure can expand or contract in size as required.

Figure shown below exemplify a linked list containing three components. Every component consists of two data items a string, and a pointer that references the next component within the list. Therefore the first component contains the string "red" the second contains "green" and the third contains "blue". The start of the list is indicated by a separate pointer, which is labeled "start". As well, the end of the list is indicated by a special pointer called as "NULL".

1623_Self-Referential Structures.png


Related Discussions:- Define the self-referential structures

#psuedocode, Create a pseudocode in getting Calendar Quarter. The program s...

Create a pseudocode in getting Calendar Quarter. The program should identify which quarter falls the given date. Note: Consider the date format DDMMYYYY.

How the operations are performed in a single linked list, Question: (a)...

Question: (a) Explain a linked list. (b) Describe the three different types of linked list with the help of diagrams. (c) Give two advantages and two disadvantages

Control structures in cpp, Control structures The control structures app...

Control structures The control structures appear in both structured programming languages as well as object oriented programming languages.  The three constructs used are: i)

What is token in programming languages, T o k e n :  Tokens  are  s...

T o k e n :  Tokens  are  small  entities  in  a  program.    Example: identifiers,  keywords,  constants, operators, strings, etc.  These tokens are used almost in same wa

Charity Ball Organizer, Charity Ball Organizer Many charities support g...

Charity Ball Organizer Many charities support good causes, but one of the difficulties each of them has is organizing their fundraising events. After nearly a semester of C pro

Explain enumerated constants, Enumerated Constants Enumerated constants...

Enumerated Constants Enumerated constants enable the creation of new types and then explain variables of these types so that their values are restricted to a set of possible va

Write a program that calculates circumference and area, Write a program cal...

Write a program called A1Q3, that reads it the radius of a circle as an integer and prints the circle's diameter, circumference and area.  Use a constant value for pi.  Do all calc

Program for greatest common divisor – c++ program, Greatest Common Divisor ...

Greatest Common Divisor (GCD) - The greatest common divisor (GCD) of two integers is the largest integer that will evenly divide both integers. The GCD algorithm involves intege

#padovan string in c, #write a program that counts the number of occurances...

#write a program that counts the number of occurances of the string in the n-th padovan string p(n)

Write Your Message!

Captcha
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