write code:
char animals[4][10] = {“MONkey”, “BEAR”, “DoG”,
“kittyKAT”};
Display all elements in animals.
Display only the uppercase letters.
2. Write a function to reverse the linked list (holds 3 Nodes).
Use only pointer operations.
head ->12->18-> 4->NULL End result: 4 ->18
->12
----------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
#include<stdio.h>
int main()
{
char
animals[4][10]={"MONkey","BEAR","DoG","kittyKAT"};
int i=0,j;
printf("---------------contents of animals
array-----------------\n");
for (i=0;i<4;i++)//printing contents
puts(animals[i]);
printf("---------------only uppercase
letters-----------------\n");
for (i=0;i<4;i++)//printing uppercase letters
{
j=0;
while(animals[i][j])
{
if
(animals[i][j]>='A'&&animals[i][j]<='Z')//checking
for uppercase characters.
printf("%c",animals[i][j]);
++j;
}
printf("\n");
}
return 0;
}
---------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------
#include<stdio.h>
#include<malloc.h>
struct node
{
int data;
struct node *next;
};
void reverse(struct node *head)
{
struct node *temp,*temp1;
temp=head->next;//interchaning data.
head->next=temp->next->next;
head->next->next=temp->next;
head->next->next->next=temp;
}
int main()
{
struct node
*head=NULL,*node1,*node2,*node3;//declaring 3 nodes
head=(struct node*)malloc(sizeof(struct
node));//allocating memory
node1=(struct node*)malloc(sizeof(struct node));
node2=(struct node*)malloc(sizeof(struct node));
node3=(struct node*)malloc(sizeof(struct node));
head->next=node1;//forming links between
nodes.after head node1
node1->next=node2;//after node1 ,node2
node2->next=node3;//after node2,node3
node3->next=NULL;//after node3 ,null
node1->data=12;//placing data
node2->data=18;
node3->data=4;
printf("---------------------------before
reverse-------------------------\n");
printf("%d->",head->next->data);
printf("%d->",head->next->next->data);
printf("%d\n",head->next->next->next->data);
reverse(head);//calling reverse funtion.
printf("---------------------------after
reverse-------------------------\n");
printf("%d->",head->next->data);
printf("%d->",head->next->next->data);
printf("%d",head->next->next->next->data);
return 0;
}
---------------------------------------------------------------------------------------------------------------------------------
"IF YOU HAVE ANY DOUBTS,PLEASE USE COMMENT SECTION"
Write code: char animals[4][10] = {“MONkey”, “BEAR”, “DoG”, “kittyKAT”}; Display all elements in ...
Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a function that finds if a given value is present in a linked-list. The function should look for the first occurrence of the value and return a true if the value is present or false if it is not present in the list. Your code should work on a linked-list of any size including an empty list. Your solution must be RECURSIVE. Non-recursive solutions will...
Please Write the following code in C: PRELAB - Week of October 14 For this prelab you will implement the following functions: List * initIntegerList() // Return empty list int insertAtHead(int k, List*) // Insert k at head int insertAtTail(int k, List*) // Insert k at tail int removeHead(List *) // Remove head and return its key int getListSize(List *) // Return number of elements in list void printHead(List *) // Print key in head void moveHeadToTail(List *) // Move...
could somone please help me to complete this ! public class MyLinkedList<AnyType> { private Node<AnyType> head, tail; private int size; public MyLinkedList() { this.head = null; this.tail = null; this.size = 0; } //1.Insert a node at the end of the list public void insert(AnyType data) { Node<AnyType> newNode = new Node(); newNode.data = data; if (head == null) { head = newNode; tail = newNode; head.next = null; tail.next = null; } else { tail.next = newNode; tail =...
ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE ANSWERING CODING SECTIONS HW07 #Q1-Q5 HW08 #Q1-Q2 // READ BEFORE YOU START: // Please read the given Word document for the project description with an illustrartive diagram. // You are given a partially completed program that creates a list of students for a school. // Each student has the corresponding information: name, standard, and a linked list of absents. // Please read the instructions...
In Java: Assume the "ferrets" variable points to a linked list of "LLNode." Write code that traverses the list and prints the following. Do not forget to consider the case where the list is empty. The "LLNode" class is given: public class LLNode { protected T info; protected LLNode link; public LLNode(T info) { this.info = info; link = null; } public void setInfo(T info) { this.info = info; } public T getInfo() { return info; } public void setLink(LLNode...
14. p contains the elements 66, 9, 14, 52, 87, 14 and 17, in that order. Consider running the following line of code: p = question4(p); where question4 is the function defined below. Show the contents of p after the function call. struct node* question4(struct node *list) { struct node* a = list; struct node* b = list; struct node* c; if (a == NULL) return NULL; while ( a->next != NULL) a = a ->next; a->next = b; c...
14. p contains the elements 66, 9, 14, 52, 87, 14 and 17, in that order. Consider running the following line of code: p = question4(p); where question4 is the function defined below. Show the contents of p after the function call. struct node* question4(struct node *list) { struct node* a = list; struct node* b = list; struct node* c; if (a == NULL) return NULL; while ( a->next != NULL) a = a ->next; a->next = b; c...
Modify the following code in order for it to perform the following operations: *This code is meant to simulate Floyd's cycle finding algorithm* A) Start with two pointers at the head of the list. We'll call the first one tortoise and the second one hare B) Advance hare by two nodes. If this is not possible because of a null pointer, we have found the end of the list, and therefore the list is acyclic C) Advance tortoise by one...
can someone please double check my code here are the requirements please help me fulfill the requirements Using the material in the textbook (NumberList) as a sample, design your own dynamic linked list class (using pointers) to hold a series of capital letters. The class should have the following member functions: append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges...
I need this in C programing And please give me complete code with screenshot of your output. onded reverze. e le defnes α node stricture identical to the list nodes for the cycle detection probem in Lab4 3. Cycle le removal (20 points). Implemeat the function break.cycleO in The prototype of the fnction s The function receives as its sole argment a poister to the the link that closwes the cycle, list. If the list contains a cycle the function...