IT issues

Question 1: Algorithms

An algorithm is defined as a set of instructions that help in accomplishing a specific task

Or to solve a specific problem step by step. The complexity of the algorithm depends on

perform tasks. Here is an example of an algorithm to find the factorial of a

number.

Step 1: Get started

Step 2: Declare variables i, x and factorial

Step 3: Initialize variable i = 1, factorial = 1

Step 4: Read the value of x

Step 5: Check if x is equal to 0

Step 5.1 When x equals 0, factorial = 1.

Step 6: else if x is not 0

Step 6.1 Repeat the following steps until i > x

Step 6.2 factorial = factorial = factorial * i

Step 6.3 i = i + 1

Step 7: Display the factorial value

Step Eight: Stop

Suppose we are looking for the factorial of three, variable x = 3. according to the above

Step, the factorial of 3 becomes 6. Note that there can be multiple

Algorithms for specific problems. This is because there can be multiple ways to achieve this

a task. For example, if we consider the algorithm above, instead of saying “repeat the following

Steps until i > x” In Step 6.1, we can say “Repeat the following steps while i <= x. "
Question 2: Linked List
exercise 2
A linked list is used when storing a list of elements in memory. List items can be
Stored somewhere in memory, each element has the address of the next element in the list. tied together
Lists can be divided into singly linked lists and doubly linked lists - the difference
In the middle is the number of fields in their nodes. Nodes have two fields in a single
Linked list, data field and next link field. On the other hand, a doubly linked list has three
field. In addition to the two fields in the singly linked list, it also contains the previous link
set up. Because of this difference, a singly linked list is more suitable when implementing a stack.
Doubly linked list is more suitable for binary tree.