Data Structure Assignment Help

Top Grade Assignment Help Brings you Data Structure Assignment Help it is a part of computing and system development unit. 

Introduction

This task is made keeping in mind the goal to get to know the ideas of data structures and calculations and to let the learner experienced and enhances his/her programming aptitudes.

Task 1

1.1 a) Explain the different types of data structures.

  1. Array – An array is a collection of homogenous type’s elements. The length of the array is greater zero and less than max value integer, each element is accessed by its numerical index.
  2. List – C# List class utilizes a dynamic cluster for putting away the components. It executes List interface. List class can contain copy components. List permits arbitrary access since cluster works at the record premise.
  3. Linked list – Linked listis a linear collection of data elements, called nodes pointing to the next node by means of a pointer. It is a data structure consisting of a group of nodes which together represent a sequence. Some keywords which are used in linked list:
  • First: First element contains in linked list called first.
  • Next: Every link contains in linked list carries a data variable and pointer called next.

The types of linked list:

  • Simple linked list
  • Doubly linked list
  • Circular linked list 

 Stack – A stack is a compartment of articles that are embedded and evacuated by toward the end of first-out (LIFO) guideline. In the push down stacks just two operations are permitted: push the thing into the stack, and pop the thing out of the stack. Some basic operations performed on stacks.

  • PUSH: Operation of inserting an item into the stack, called PUSH.
  • POP: Operation of removing an item from the stack called POP. 

Queue – A queue is a container of items (a direct accumulation) that are embedded and expelled by first-in-first-out (FIFO) rule. A phenomenal case of a queue is a line of students. New increases in a line made to the back of the line, while expulsion (or serving) happens in the front. In the queue just two operations are permitted en queue and de queue. En queue intends to embed a thing into the back of the queue, de queue implies expelling the front thing.

Tree – Tree is an abstract data type which is connected, undirected, a cyclic graph. It is a collection of nodes, and each node connected in a hierarchy with an edge and contains zero or maximum two nodes. Read more about System Analysis and design Assignment 

Some important terms used in tree data structure:

  • Root node: Top node of the tree is called Root. Any tree contains only one root node.
  • Path: The path known as sequence of the node along with the edge of the tree.
  • Parent node: The node has one edge point to up node called parent node
  • Child: The node which is connected to down node called child node.
  • Leaf: The node of the tree, which has no any connected child node, is called leaf. 

Data Structure Assignment Help, top grade assignment help, top grade assignment, technical assignment help, programming assignment help

Figure 1 tree data structure 

Sets – Collection of objects known as a set. The set of zero elements is called empty or null set. It performs some mathematical operation, such as:

  • Union
  • Intersection
  • Differences
  • Subset

Types of Sets: static and dynamic

 Strings- String knows as a sequence of characters may be with literal constant and some kind of variables. The size of the string can vary according to value.

Strings are implemented as a record in programming, example:

class string {

unsigned int length;

char *text;

};

An example of a non-terminated string.

Data Structure Assignment Help, top grade assignment help, top grade assignment, technical assignment help, programming assignment help

Figure 2 non-terminated string stored in 10-byte 

1.2  With the aid of pseudo-code or flow charts, explain the operation.

  1. Bubble sort

          Pseudocode

BubbleSort( int a[], int n)

Beginfor i = 1 to n-1

sorted = true

for j = 0 to n-1-i

If a[j] > a [j+1]

temp = a[j]

a[j] = a[j+1]

a[j+1] = temp

sorted = false

end for if sorted

break from i loop

end for

End

  1. Insertion sort 

Insertion Sort(array A)

LOOP  i <- 1 to length[A]-1 do

value := A[i]

j <- i-1

LOOP j >= 0 and A[j] > value do

A[j+1] <- A[j]

j <- j-1

END

A[j+1] = value

END

  1. Quick sort

Quicksort(A as array, low as int, high as int){

if (low < high){

pivot = Partition(A,low,high)

Quicksort(A,low, pivot)

Quicksort(A, pivot + 1, high)

}

}

Partition(A as array, low as int, high as int){

pivot = A[low]

LW= low

for i = low + 1 to high{

if (A[i] < pivot) then{

swap(A[i], A[LW])

LW= LW+ 1

}

}

swap(pivot,A[LW])

return (LW)

}

  1. Sequential search

sequentialsearch(list L,item x)

{

For (each item y in the list)

if (y matches x)

return y

return no match

}

  1. Binary search

binarySearch(arr, value, low,high)

LOOP WHILE low<=high AND Value Not Found

mid <- (low + high)/2

IF arr[mid] = value

Return Value Found

Else

IF arr[mid] < value

low <- mid + 1

Else

High <- mid -1

END LOOP

Return Value Not Found

1.3  Design pseudo-codes and flow charts to demonstrate recursive algorithms used in the following:

(1) Calculating the factorial

class Program

{

static void Main(string[] args)

{

//to store user input and result

long number, fact;

Console.Write(“Please Input Number “);

number = long.Parse(Console.ReadLine());

//calculate factorial

fact = Factorial(number);

Console.WriteLine(“Factorial of ” + number +” is ” + fact);

Console.Read();

}

/// <summary>

/// returns factorial of a given number

/// </summary>

/// <param name=”number”></param>

/// <returns></returns>

public static long Factorial(long number)

{

if (number <= 1)

return 1;

else

return number * Factorial(number – 1);//call Factiorial again

}

} 

Data Structure Assignment Help, top grade assignment help, top grade assignment, technical assignment help, programming assignment help

Figure 3 Factorial Flowchart

(2) Euclid algorithm to find the GCD of two numbers

class Program

{

static void Main(string[] args)

{

//to store user input

int no1, no2;

Console.WriteLine(“Please input two Numbers “);

//read numbers

no1 = int.Parse(Console.ReadLine());

no2 = int.Parse(Console.ReadLine());

//get gcd

int gcd = GCD(no1, no2);

//printing the result

Console.WriteLine(“GCD is “+gcd);

Console.Read();

}

//recursive function to calculate GCD

public static int GCD(int no1, int no2)

{

//if no2 is 0, no1 is returned

if (no2 == 0)

{

return no1;

}

else

{

return GCD(no2, no1 % no2);

}

}

} 

(3) Fibonacci series. As an optional exercise, you may find it interesting to write a C# or Java code for this.

class Program

{

public static void Main(String[] args)

{

Console.Write(“Input number to print series: “);

int no = int.Parse(Console.ReadLine());

Console.WriteLine(“Fibonacci series upto ” + no + “\n”);

//generating series

int i=1;

while(i<=no)

{

Console.Write(“{0} “, Fibbonacci(i));

i++;

}

Console.Read();

}

public static int Fibbonacci(int no){

if(no == 1 || no == 2){

return 1;

}

return Fibbonacci(no-1) + Fibbonacci(no -2);

}

}

Data Structure Assignment Help, top grade assignment help, top grade assignment, technical assignment help, programming assignment help

Figure 4 Fibonacci flowchart

Read more about Dot Net Assignment help

Task 2

2.1  Generates an array of 1 million random integers. Perform bubble sort, insertion sort and quick sort to use on this array. Time each algorithm and compare the times.

Visual Studio Coding

class Program

{

const int MAX = 10000;

static void Main(string[] args)

{

Console.WriteLine(“Total Numbers : ” + MAX);

Console.Write(“\nRandom number generation in progress …. “);

int[] numbers = GenerateRandomNumbers(MAX);

Console.WriteLine(“Bubble Sorting in progress …. “);

TimeSpan bubbleSortTime = BubbleSortArray(numbers);

Console.Write(“Random number generation in progress …. “);

numbers = GenerateRandomNumbers(MAX);

Console.WriteLine(“Quick Sort in progress …. “);

TimeSpan tsQuickSort = QuickSortArray(numbers, 0, MAX – 1);

Console.Write(“Random number generation in progress …. “);

numbers = GenerateRandomNumbers(MAX);

Console.WriteLine(“Insertion Sort in progress …. “);

TimeSpan tsInsertionSort = InsertionSortArray(numbers);

Console.WriteLine(“\n\nTime Bubble Sorting     >> “+bubbleSortTime.TotalMilliseconds);

Console.WriteLine(“Time Quick Sorting      >> ” + tsQuickSort.TotalMilliseconds);

Console.WriteLine(“Time Insertion Sorting  >> ” + tsInsertionSort.TotalMilliseconds);

Console.Read();

}

private static int[] GenerateRandomNumbers(int max){

int[] array = new int[max];

Random rand = new Random();

int tmp;

for(int counter = 0; counter < max;counter++){

tmp = rand.Next(1, max+1);

if (array.Contains(tmp)){        counter–;       }

else{   array[counter] = tmp;           }

}

return array;

}

private static TimeSpan QuickSortArray(int[] nubmersArray, int LEFT, int RIGHT)

{

DateTime startTime = DateTime.Now;

if (LEFT < RIGHT)

{

int PVT = PartitionArray(nubmersArray, LEFT, RIGHT);

if (PVT > 1)

QuickSortArray(nubmersArray, LEFT, PVT – 1);

if (PVT + 1 < RIGHT)

QuickSortArray(nubmersArray, PVT + 1, RIGHT);

}

return DateTime.Now – startTime;

}

private static int PartitionArray(int[] array, int LEFT, int RIGHT)

{

int PVT = array[LEFT];

while (true)

{

while (array[LEFT] < PVT)

LEFT++;

while (array[RIGHT] > PVT)

RIGHT–;

if (LEFT < RIGHT)

{

int tmp = array[RIGHT];

array[RIGHT] = array[LEFT];

array[LEFT] = tmp;

}

else

{

return RIGHT;

}

}

}

private static TimeSpan InsertionSortArray(int[] numbersArray)

{

DateTime startTime = DateTime.Now;

for (int k = 1; k < numbersArray.Length; k++)

{

int l = k;

for (; l > 0; )

{

if (numbersArray[l – 1] > numbersArray[l])

{

int tmp = numbersArray[l – 1];

numbersArray[l – 1] = numbersArray[l];

numbersArray[l] = tmp;

l–;

}

else

break;

}

}

return DateTime.Now – startTime;

}

private static TimeSpan BubbleSortArray(int[] numbersArray)

{

DateTime startTime = DateTime.Now;

bool f = true;

int tmp;

int len = numbersArray.Length;

for (int k = 1; (k <= (len – 1)) && f; k++)

{

f = false;

for (int l = 0; l < (len – 1); l++)

{

if (numbersArray[l + 1] > numbersArray[l])

{

tmp = numbersArray[l];

numbersArray[l] = numbersArray[l + 1];

numbersArray[l + 1] = tmp;

f = true;

}

}

}

return DateTime.Now – startTime;

}

}

 Output Screens

Data Structure Assignment Help, top grade assignment help, top grade assignment, technical assignment help, programming assignment help

Figure 6 output

Data Structure Assignment Help, top grade assignment help, top grade assignment, technical assignment help, programming assignment help

Figure 7 time V/s array size

In this graph, it is clear that the quick sort takes lesser time to sort data elements as compare to other sorting algorithms. Insertion sort takes an average time while bubble sort consumes the largest time to sort data elements.

Read more about Android Assignment Help

2.2  Perform sorting on some strings

class Program

{

const String fName = “A.txt”;

static void Main(string[] args)

{

if(!File.Exists(fName)){

Console.WriteLine(“File Was Not Found. Program Will Treminate.”);

Console.Read();return;

}

String contentsFromFile = File.ReadAllText(fName);

if (contentsFromFile.Length <= 0){

Console.WriteLine(“No contents. Check File. Program Will Treminate.”);

Console.Read();return;

}

String[] strings = contentsFromFile.Split(new char[] { ‘ ‘, ‘.’, ‘,’, ‘\n’ });

Console.WriteLine(“Number of Stings are >> ” + strings.Length);

Console.WriteLine(“Peforming BUBBLE SORT …. “);

TimeSpan tsBubbleSort = StringBubbleSort(strings);

strings = contentsFromFile.Split(new char[] { ‘ ‘, ‘.’, ‘,’,’\n’ });

Console.WriteLine(“Peforming QUICK SORT …. “);

TimeSpan tsQuickSort = StringQuickSort(strings, 0, strings.Length – 1);

strings = contentsFromFile.Split(new char[] { ‘ ‘, ‘.’, ‘,’, ‘\n’ });

Console.WriteLine(“Peforming INSERTION SORT …. “);

TimeSpan tsInsertionSort = StringInsertionSort(strings);

Console.WriteLine(“\n\nTime for BUBBLE SORT     :: ” + tsBubbleSort.TotalMilliseconds);

Console.WriteLine(“Time for QUICK SORT      :: ” + tsQuickSort.TotalMilliseconds);

Console.WriteLine(“Time for INSERTION SORT  :: ” + tsInsertionSort.TotalMilliseconds);

Console.Read();

}

private static TimeSpan StringBubbleSort(String[] stringsArray)

{

DateTime startTime = DateTime.Now;

bool f = true;

String tmp;

int len = stringsArray.Length;

for (int k = 1; (k <= (len – 1)) && f; k++)

{

f = false;

for (int l = 0; l < (len – 1); l++){

if ( stringsArray[l + 1].CompareTo(stringsArray[l]) < 0){

tmp = stringsArray[l];

stringsArray[l] = stringsArray[l + 1];

stringsArray[l + 1] = tmp;

f = true;

}

}

}

return DateTime.Now – startTime;

}

private static TimeSpan StringInsertionSort(String[] array)

{

DateTime startTime = DateTime.Now;

for (int k = 1; k < array.Length; k++)

{

int l = k;

while (l > 0){

if (array[l – 1].CompareTo(array[l])>0)

{

String tmp = array[l – 1];

array[l – 1] = array[l];

array[l] = tmp;

l–;

}

else

break;

}

}

return DateTime.Now – startTime;

}

public static TimeSpan StringQuickSort(IComparable[] elements, int LEFT, int RIGHT)

{

DateTime startTime = DateTime.Now;

int k = LEFT, l = RIGHT;

IComparable PVT = elements[(LEFT + RIGHT) / 2];

for (; k <= l; ){

while (elements[k].CompareTo(PVT) < 0){ k++; }

while (elements[l].CompareTo(PVT) > 0){ l–; }

if (k <= l){

IComparable temp = elements[k];

elements[k] = elements[l];

elements[l] = temp;

k++;l–;

}

}

if (LEFT < l){  StringQuickSort(elements, LEFT, l);   }

if (k < RIGHT){ StringQuickSort(elements, k, RIGHT);  }

return DateTime.Now -startTime ;

}

}

2.3 To design Priority Manager

Data Structure Assignment Help, top grade assignment help, top grade assignment, technical assignment help, programming assignment help

Figure 8 displaying all tasks

Data Structure Assignment Help, top grade assignment help, top grade assignment, technical assignment help, programming assignment help

Figure 9 after deletion of some tasks

Task3

3.1 a) Explain these common string operations and give a real-world application example for each

(i) String length: string length is the total number of characters in sequence till trail. If there is no character in the string the length of string will be zero. The range of string length zero to maximum value integer.

(ii) String comparison: The string comparison knows as a method of comparing two strings and portion of the string. The string can compare with another string by sorting them in alphabetical order.

(iii) Changing string cases from upper to lower and vice versa: It is used to convert character cases of a string. It is commonly needed a task that we need to convert a string from lower case to upper case or from upper case to lower case. Read about : PHP Assignment Help

(iv)Ordering strings: Ordering is needed when we want to sort strings alphabetically. Suppose that we have a list of names and we want to arrange them alphabetically then we have to use this approach

(v) String manipulation (splitting, concatenation, character position, and string or character extraction

String modification is the process of modifying and investigating the string. It is a basic operation on the strings, like splitting, concatenation, to find a character position in a string or to extract a character or portion of a string, replacing substrings by another string.

We can perform following operations.

Splitting: it breaks the string into substrings using delimiter that we specify.

Concatenation: Concatenation is the process of joining two or more strings together by using the addition operator “+” in c#.

Character position: It is used to get or set a character on a particular position in a string.

b) Perform various on a string.

class Program

{

public static void Main(String[] args)

{

String str = “Arsenal do not win the 2015-2016 premier league season, Arsene Wenger should hand in his resignation on Sunday 15 May 2016 at 3PM”;

Console.Write(“String is :\n” + str);

Console.Write(“\n\nSorted String :\n”);

sortString(str);

String strWithoutSpaces = removeSpaces(str);

Console.Write(“\nString Without Spaces :\n” + strWithoutSpaces);

Console.Write(“\nInput a Character to check”);

String input = Console.ReadLine();

char userChar = input[0];

positonOfCharacter(str, userChar);

Console.Write(“\n\nInput a word to extract”);

String userWord = Console.ReadLine();

getWord(str, userWord);

Console.Read();

}

private static String removeSpaces(String str)

{

return str.Replace(” “, “”);

}

private static void positonOfCharacter(String str, char ch1)

{

int c = 0;

for (int i = 0; i < str.Length; i++)

{

char ch2 = str[i];

if (ch2 == ch1){

Console.WriteLine(“matchd at Position :” + i);

c++;

}

}

if (c < 1)

Console.WriteLine(“Sorry string doesn’t contain ‘” + ch1 + “‘ character”);

}

private static void getWord(String str, String w)

{

int i = str.ToLower().IndexOf(w.ToLower());

if (str.ToLower().IndexOf(w.ToLower()) != -1){

Console.WriteLine(w + ” Macthed at position ” + i);

}

else{

Console.WriteLine(“Not Found”);

}

}

private static void sortString(String s)

{

char[] charArr = s.ToCharArray();

Array.Sort(charArr);

String str = new String(charArr);

Console.WriteLine(str);

}

}

Read more about Online Assignment Help

3.2 Program to check string palindrome

public static bool IsPalindrome(String inputString)

{

for (int i = 0; i < (inputString.Length / 2); i++)

{

if (inputString[i] != inputString[inputString.Length – i – 1])

{

return false;

}

}

return true;

}

Read more about Assignment Help Australia 

Conclusion

Implementation of this assessment will increase the knowledge of data structure and algorithms and various sorting algorithms. It will help in to write code more easily and efficiently. Data structure is all about that how to map a new problem with a known problem. It is a good practice and increases hold on programming languages.

Top Grade Assignment help provide technical assignment writing service based on case study requirements in affordable prices and we are providing most flexible online assignment writing help, so book your Assignment with us, order now

About the Author

Alice