Write a function that sets the value of an integer

Assignment Help C/C++ Programming
Reference no: EM131617473

Assignment

1. Write a function set(int* a, int val) that sets the value of an integer a declared in the calling function, to the value val. Print the value of the integer from the calling function both prior to and after calling the set function.

2. Write the function swapInts(int*, int*) that swaps the values of two integers. From the calling function, print the values of two pointers before and after the swap.

3. Write the function swapPtrs(int**, int**) that swaps two pointers. From the calling function, print the values of the two integers before and after the swap.

4. Implement a singly-linked list of integers. Write the function findNthElement(struct listnode* head, int N) which returns the Nth element of the list. Print the contents of your list and the value of the Nth element on separate lines.

5. Implement a singly-linked list of integers. Write the function removeNthElement(struct listnode* head, int N) which removes the Nth element of the list. Print the contents of the list before and after removal of the Nth element.

6. Implement a singly-linked list of integers. Write the function findNthToLastElement(struct listnode* head, int N) which returns the Nth element counting from the END of the list. Print the contents of the list as well as the Nth to last element on separate lines.

7. Implement a doubly-linked list. Write the function reverse(struct listnode** head) which reverses the list by swapping the previous and next pointers of each node. Print the contents of the list before and after the reversal.

8. Using your doubly-linked list and reverse function, write a function isPalyndrome(struct listnode* head) that returns 1 if the string encoded in your list is a palyndrome and 0 if it is not.

9. Construct a binary search tree (BST) that stores integers (i.e. the descendants to the left of a node are less than or equal to the node and the descendants to the right of the node are greater than or equal to the node). Insert integers 100, 75, 50, 125, 25, 150 into the tree. Write the function preorderPrint(treenode*) that uses recursion to perform a preorder traversal of the tree and print the values.

10. See previous problem. Write the function nr_preorder_print(treenode*) that performs a preorder traversal of the tree WITHOUT recursion. Instead, implement a stack (singly-linked list manipulated with push(...)/pop(...) functions) to aid with the traversal.

11. Write the function bitcount(unsigned x) that returns the number of 1-bits in the unsigned integer argument x.

12. Write the function invert(unsigned int x, int p, int n) that returns x with the n bits that begin in position p inverted, leaving the others unchanged. Example: x = 0000 1111 1010 1010 1010 p = 7 n = 5 y = invert(x, p, n) = 0000 1110 0101 1010 1010

13. Write the function rightRot(int x, int n) that returns the value of the integer x rotated to the right by n bit positions. Example: x = 0000 0000 0011 1100 y = rightRot(x, 4) = 1100 0000 0000 0011

14. Write the function setBits(int x, int p, int n, int y) that returns x with the n bits that begin at position p set to the rightmost n bits of y. All other bits should remain unchanged. Example: x = 1010 1010 1010 1010 y = 1100 1100 1100 1100 z = setBits(x, 2, 4, y) = 1011 0010 1010 1010

Reference no: EM131617473

Questions Cloud

Determine approximate surface temperature of the resistor : A 0.1-W small cylindrical resistor mounted on a lower part of a vertical circuit board is 0.3 in long and has a diameter of 0.2 in.
What would you do in your program to avoid the pitfalls : CIS Discussion: Text File Processing- What would you do in your program to avoid these pitfalls when working with text file in your program?
Based on a before-tax analysis-should the lift be installed : The owner of a ski resort is considering installing a new ski lift that will cost $800,000. Based on a before-tax analysis, should the lift be installed?
What is your best estimate of aftertax cost of debt : What is the company's total book value of debt? What is your best estimate of the aftertax cost of debt?
Write a function that sets the value of an integer : Write a function set(int* a, int val) that sets the value of an integer a declared in the calling function, to the value val.
Create a decision tree and recommend the appropriate action : Explain the methodology utilized to create a decision tree and recommend the appropriate action to take based on your decision tree from criterion 5.
Provide an oral advice on the law to the client : Provide an oral advice on the law to the client in the form of a YouTube video, weighing up the alternatives and providing a recommendation.
What is the expected return on this stock : The market risk premium is 9.3 percent and the risk-free rate is 4.6 percent. What is the expected return on this stock?
What is the history of right to work laws : What is the history of 'Right to Work' laws? Where did they come from? Who proposed them and why? Has their purpose or effect changed since original inception?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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