Data Structures and Operations
VerifiedAdded on 2023/03/21
|19
|1986
|100
AI Summary
This document provides an overview of different data structures such as array, linked list, stack, queue, tree, and strings. It explains the concept of each data structure and the available operations on them. The document also includes sample code for factorial, Fibonacci series, random function and sorting, and string manipulation.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
Running head: BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
BTEC HND in Computer Systems Development
Name of the Student
Name of the University
Authors note
BTEC HND in Computer Systems Development
Name of the Student
Name of the University
Authors note
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
1BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
Data structures and valid operations on them
Data structure: Array
An array data structures is considered as the collection of similar stored data elements
stored in at contiguous locations in the memory. The main concept behind this data structure
is the to store multiple same types of data type together. In this way it becomes easier to
calculate the required memory as well as the position of every element in the memory as they
take the same amount of space while by simply adding offset value to the base value or the
starting position (i.e., memory location of the first element) stored in the array.
Available operations on Array
Traversal of the elements − This operation prints all array elements one by one as
stored in array.
Insertion of the elements – Adding element to the array at given index.
Deletion – Deletion of the element from a given index.
Search – Searching for a specific element using the index or value.
Update – This operation is helpful in updating an element at an index.
Data structure: Array list
The Array list can be defined as the resizable arrays that makes the use of the list
interface. The size of array list can be shrunk or grow according to the requirement of the
application that is using it. The elements in the array list can be accessed randomly.
Available operations
Insertion of the element
Traversal and printing
Data structures and valid operations on them
Data structure: Array
An array data structures is considered as the collection of similar stored data elements
stored in at contiguous locations in the memory. The main concept behind this data structure
is the to store multiple same types of data type together. In this way it becomes easier to
calculate the required memory as well as the position of every element in the memory as they
take the same amount of space while by simply adding offset value to the base value or the
starting position (i.e., memory location of the first element) stored in the array.
Available operations on Array
Traversal of the elements − This operation prints all array elements one by one as
stored in array.
Insertion of the elements – Adding element to the array at given index.
Deletion – Deletion of the element from a given index.
Search – Searching for a specific element using the index or value.
Update – This operation is helpful in updating an element at an index.
Data structure: Array list
The Array list can be defined as the resizable arrays that makes the use of the list
interface. The size of array list can be shrunk or grow according to the requirement of the
application that is using it. The elements in the array list can be accessed randomly.
Available operations
Insertion of the element
Traversal and printing
2BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
Searching specific element
Removal of elements
Sorting elements of the array list.
Data structure: Linked list
The Linked list is represented as a linear data structure. In this data structure, the
elements in the data structure is not stored at contiguous locations of the memory. The
elements stored inside any linked list are connected using pointers in each node along with
the data part with the node.
Insertion of elements − This operation is helpful in adding an element at the
beginning of linked list.
Deletion − Deletes an element from the beginning.
Display – prints all the elements in the linked list.
Searching of an element− Searches for an element with a given key.
Deletion − Deletes an element.
Data structure: Stack
Stack is another abstract data structure that had predefined capacity for certain
number of elements. This kind of data structure can be considered as a simple data structure
which only allows addition/removal of elements in some specific order. Whenever an
element is added to the stack then the it always is stored on the top of stack data structure. In
the similar manner whenever an element is removed from the stack, then the last inserted
element on the top is first removed.
Searching specific element
Removal of elements
Sorting elements of the array list.
Data structure: Linked list
The Linked list is represented as a linear data structure. In this data structure, the
elements in the data structure is not stored at contiguous locations of the memory. The
elements stored inside any linked list are connected using pointers in each node along with
the data part with the node.
Insertion of elements − This operation is helpful in adding an element at the
beginning of linked list.
Deletion − Deletes an element from the beginning.
Display – prints all the elements in the linked list.
Searching of an element− Searches for an element with a given key.
Deletion − Deletes an element.
Data structure: Stack
Stack is another abstract data structure that had predefined capacity for certain
number of elements. This kind of data structure can be considered as a simple data structure
which only allows addition/removal of elements in some specific order. Whenever an
element is added to the stack then the it always is stored on the top of stack data structure. In
the similar manner whenever an element is removed from the stack, then the last inserted
element on the top is first removed.
3BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
Valid operations on the stack data structure
There are usually three operations are available for stack data structure which is
traversal, push and pop. Through the push an element is stored in the stack, using pop an
element is deleted from the stack and traversal is helpful in the displaying all the elements
stored in the stack.
Data structure: Queue
Similar to the stack, the queue is another liner data structure that acts as first in first
out manner. In this data structure first element is inserted at the one end or the REAR end.
On the contrary to the stack the removal of an element is takes place from another end which
is denoted as FRONT or the head. In this way the queue becomes an FIFO (First in First
Out) data structure. Therefore, an element inserted first is removed first.
Following are the valid operations on the queue data structure; Traversal of the
elements to access all the elements, Enque or the addition of the elements, Deque or deletion
of an element - This is the process of accessing each and every element of the queue.
Searching for an element and finally merging two queues.
Data structure: Tree
The tree abstract is a recursive collection of data nodes that starts from a root
node. Each of the node consist of a value as well as list of references to the last and next
nodes or to the children nodes. In the tree data structure, the no duplicate constraint is applied
and none of the child nodes points to the root.
Valid operations on the stack data structure
There are usually three operations are available for stack data structure which is
traversal, push and pop. Through the push an element is stored in the stack, using pop an
element is deleted from the stack and traversal is helpful in the displaying all the elements
stored in the stack.
Data structure: Queue
Similar to the stack, the queue is another liner data structure that acts as first in first
out manner. In this data structure first element is inserted at the one end or the REAR end.
On the contrary to the stack the removal of an element is takes place from another end which
is denoted as FRONT or the head. In this way the queue becomes an FIFO (First in First
Out) data structure. Therefore, an element inserted first is removed first.
Following are the valid operations on the queue data structure; Traversal of the
elements to access all the elements, Enque or the addition of the elements, Deque or deletion
of an element - This is the process of accessing each and every element of the queue.
Searching for an element and finally merging two queues.
Data structure: Tree
The tree abstract is a recursive collection of data nodes that starts from a root
node. Each of the node consist of a value as well as list of references to the last and next
nodes or to the children nodes. In the tree data structure, the no duplicate constraint is applied
and none of the child nodes points to the root.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
4BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
Valid operations on the Tree
Insertion of the nodes − Inserts an element in a tree/create a tree.
Searching an element in the tree.
Preorder Traversal of the elements in the tree.
Inorder Traversal of the elements in tree.
Postorder Traversal of the elements in a tree.
Data structure: Strings
Strings data structures are the array of characters. The difference among a character
array and string is the string abstract data structure ends with the \0.
The valid operations are strlen to check the length, strcpy to copy an string, strcmp
for comparing two strings, strstr to find the occurrence of a substring.
Factorial Program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Factorial
{
Valid operations on the Tree
Insertion of the nodes − Inserts an element in a tree/create a tree.
Searching an element in the tree.
Preorder Traversal of the elements in the tree.
Inorder Traversal of the elements in tree.
Postorder Traversal of the elements in a tree.
Data structure: Strings
Strings data structures are the array of characters. The difference among a character
array and string is the string abstract data structure ends with the \0.
The valid operations are strlen to check the length, strcpy to copy an string, strcmp
for comparing two strings, strstr to find the occurrence of a substring.
Factorial Program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Factorial
{
5BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter number for calculating factorial");
int num = Convert.ToInt32(Console.ReadLine());
long factr = RecurFactorial(num);
Console.WriteLine("{0} factorial is {1}", num, factr);
Console.ReadKey();
}
private static long RecurFactorial(int num)
{
if (num == 0)
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter number for calculating factorial");
int num = Convert.ToInt32(Console.ReadLine());
long factr = RecurFactorial(num);
Console.WriteLine("{0} factorial is {1}", num, factr);
Console.ReadKey();
}
private static long RecurFactorial(int num)
{
if (num == 0)
6BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
{
return 1;
}
return num * RecurFactorial(num - 1);
}
}
}
Fibonacci
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
{
return 1;
}
return num * RecurFactorial(num - 1);
}
}
}
Fibonacci
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
7BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
namespace ConsoleApp1
{
class Program
{
public static int Fibonacci(int num)
{
if (num == 0) return 0;
if (num == 1) return 1;
return Fibonacci(num - 1) + Fibonacci(num - 2);
}
static void Main(string[] args)
{
{
Console.Write("Enter the count of the elements in Fibbonacci series: ");
int length = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < length; i++)
{
Console.Write("{0} ", Fibonacci(i));
}
namespace ConsoleApp1
{
class Program
{
public static int Fibonacci(int num)
{
if (num == 0) return 0;
if (num == 1) return 1;
return Fibonacci(num - 1) + Fibonacci(num - 2);
}
static void Main(string[] args)
{
{
Console.Write("Enter the count of the elements in Fibbonacci series: ");
int length = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < length; i++)
{
Console.Write("{0} ", Fibonacci(i));
}
8BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
Console.ReadKey();
}
}
}
}
Random function and sorting
Flowchart
Console.ReadKey();
}
}
}
}
Random function and sorting
Flowchart
9BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
10BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System;
using System.IO;
namespace ConsoleApp1
{
class Program
{
void inssort(int[] arra)
{
int n = arra.Length;
for (int i = 1; i < n; ++i)
{
int keys = arra[i];
int j = i - 1;
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System;
using System.IO;
namespace ConsoleApp1
{
class Program
{
void inssort(int[] arra)
{
int n = arra.Length;
for (int i = 1; i < n; ++i)
{
int keys = arra[i];
int j = i - 1;
11BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
while (j >= 0 && arra[j] > keys)
{
arra[j + 1] = arra[j];
j = j - 1;
}
arra[j + 1] = keys;
}
}
static void printsortArray(int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n; ++i)
Console.Write(arr[i] + " ");
Console.Write("\n");
}
static void Main(string[] args)
{
while (j >= 0 && arra[j] > keys)
{
arra[j + 1] = arra[j];
j = j - 1;
}
arra[j + 1] = keys;
}
}
static void printsortArray(int[] arr)
{
int n = arr.Length;
for (int i = 0; i < n; ++i)
Console.Write(arr[i] + " ");
Console.Write("\n");
}
static void Main(string[] args)
{
12BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
int count = 500;
Random rn = new Random();
int[] numbers = new int[count];
//int minRange = 2, maxRange = 700;
TextWriter tw = new StreamWriter("data.txt");
for (int l = 0; l < 500; l++)
{
//int p=rn.Next(max);
int p = rn.Next(0,650) + rn.Next(8,45);
numbers[l] = p;
tw.WriteLine(p);
Console.WriteLine(p);
System.Threading.Thread.Sleep(200);
}
Program sc = new Program();
Console.WriteLine("Sorting started");
int count = 500;
Random rn = new Random();
int[] numbers = new int[count];
//int minRange = 2, maxRange = 700;
TextWriter tw = new StreamWriter("data.txt");
for (int l = 0; l < 500; l++)
{
//int p=rn.Next(max);
int p = rn.Next(0,650) + rn.Next(8,45);
numbers[l] = p;
tw.WriteLine(p);
Console.WriteLine(p);
System.Threading.Thread.Sleep(200);
}
Program sc = new Program();
Console.WriteLine("Sorting started");
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
13BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
sc.inssort(numbers);
printsortArray(numbers);
tw.Close();
}
}
}
LO 3: String Manipulation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stack_
{
sc.inssort(numbers);
printsortArray(numbers);
tw.Close();
}
}
}
LO 3: String Manipulation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stack_
{
14BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
class Stack
{
private int[] ele;
private int top;
private int max;
public Stack(int size)
{
ele = new int[size];
top = -1;
max = size;
}
public void push(int item)
{
if (top == max - 1)
{
Console.WriteLine("Stack Overflow");
return;
}
else
class Stack
{
private int[] ele;
private int top;
private int max;
public Stack(int size)
{
ele = new int[size];
top = -1;
max = size;
}
public void push(int item)
{
if (top == max - 1)
{
Console.WriteLine("Stack Overflow");
return;
}
else
15BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
{
ele[++top] = item;
}
}
public int pop()
{
if (top == -1)
{
Console.WriteLine("Stack Underflow");
return -1;
}
else
{
Console.WriteLine("Poped element is: " + ele[top]);
return ele[top--];
}
}
public void printStack()
{
ele[++top] = item;
}
}
public int pop()
{
if (top == -1)
{
Console.WriteLine("Stack Underflow");
return -1;
}
else
{
Console.WriteLine("Poped element is: " + ele[top]);
return ele[top--];
}
}
public void printStack()
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
16BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
{
if (top == -1)
{
Console.WriteLine("Stack is Empty");
return;
}
else
{
for (int i = 0; i <= top; i++)
{
Console.WriteLine("Item[" + (i + 1) + "]: " + ele[i]);
}
}
}
}
class Program
{
static void Main(string[] args)
{
if (top == -1)
{
Console.WriteLine("Stack is Empty");
return;
}
else
{
for (int i = 0; i <= top; i++)
{
Console.WriteLine("Item[" + (i + 1) + "]: " + ele[i]);
}
}
}
}
class Program
{
static void Main(string[] args)
17BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
{
System.Console.WriteLine("Enter the size of element");
int nsz = (int)(Console.ReadKey().KeyChar);
//Convert.ToInt32(System.Console.ReadKey());
Stack S = new Stack(nsz);
for (int y = 0; y <= nsz; y++)
{
System.Console.WriteLine("Enter value to push into the stack");
S.push((int)(Console.ReadKey().KeyChar));
}
//.push(10);
//S.push(20);
//S.push(30);
//S.push(40);
//S.push(50);
Console.WriteLine("Items are : ");
S.printStack();
{
System.Console.WriteLine("Enter the size of element");
int nsz = (int)(Console.ReadKey().KeyChar);
//Convert.ToInt32(System.Console.ReadKey());
Stack S = new Stack(nsz);
for (int y = 0; y <= nsz; y++)
{
System.Console.WriteLine("Enter value to push into the stack");
S.push((int)(Console.ReadKey().KeyChar));
}
//.push(10);
//S.push(20);
//S.push(30);
//S.push(40);
//S.push(50);
Console.WriteLine("Items are : ");
S.printStack();
18BTEC HND IN COMPUTER SYSTEMS DEVELOPMENT
//S.pop();
System.Console.WriteLine("First item popped");
S.pop();
//S.pop();
//sleep(500);
System.Console.ReadKey();
}
}
}
//S.pop();
System.Console.WriteLine("First item popped");
S.pop();
//S.pop();
//sleep(500);
System.Console.ReadKey();
}
}
}
1 out of 19
Related Documents
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024 | Zucol Services PVT LTD | All rights reserved.