Free Essay

Linkedlist

In:

Submitted By hero1
Words 2375
Pages 10
Linked List

1

List vs Arrays
Two built-in data structures that can be used to organize data, or to create other data structures:

• Lists • Arrays

Lists
A list is an ordered set of data. It is often used to store objects that are to be processed sequentially.

Arrays
An array is an indexed set of variables, such as dancer[1], dancer[2], dancer[3],… It is like a set of boxes that hold things. A list is a set of items. An array is a set of variables that each store an item.

Arrays and Lists
You can see the difference between arrays and lists when you delete items.

Arrays and Lists
In a list, the missing spot is filled in when something is deleted.

Arrays and Lists
In an array, an empty variable is left behind when something is deleted.

What’s wrong with Array and Why lists? • Disadvantages of arrays as storage data structures:
– slow searching in unordered array – slow insertion in ordered array – Fixed size

• Linked lists solve some of these problems • Linked lists are general purpose storage data structures and are versatile.

Linked Lists

A
Head

B

C



• A linked list is a series of connected nodes • Each node contains at least
– A piece of data (any type) – Pointer to the next node in the list

• Head: pointer to the first node • The last node points to NULL

node

A data pointer

The composition of a Linked List

• A linked list is called "linked" because each node in the series has a pointer that points to the next node in the list.

10

Linked Lists

• Each data item is embedded in a link. • Each Link object contains a reference to the next link in the list of items. • In an array items have a particular position, identified by its index. • In a list the only way to access an item is to traverse the list

Declarations to create a node

• First you must declare a data structure that will be used for the nodes. For example, the following struct could be used to create a list where each node holds a data: struct Node { int data; Node *next; };
12

data

Declarations
• The next step is to declare a pointer to serve as the list head, as shown below.
Node *head;

• Once you have declared a node data structure and have created a NULL head pointer, you have an empty linked list. • The next step is to implement operations with the list.
13

Operations in a simple linked list:
• Add or Append a node in the list void appendNode(value); • Insert a node in the list void insertNode(value); • Delete a node from the list void deleteNode(value); • Iterate through the list to display items.

void isplayList(value);

Adding or Appending a Node to the List

• To append a node to a linked list means to add the node to the end of the list. • The pseudocode is shown below. The C++ code follows. Create a new node. Store data in the new node. If there are no nodes in the list Make the new node the first node. Else Traverse the List to Find the last node. Add the new node to the end of the list. End If.
15

Void appendNode(int value)
{
Node *newNode, *curr; // Allocate a new node & store data newNode = new Node; newNode->data = value; newNode->next = NULL; // If there are no nodes in the list // make newNode the first node if (!head) head = newNode; else // Otherwise, insert newNode at end { // Initialize curr to head of list curr = head; // Find the last node in the list while (curr->next) curr = curr->next; // Insert newNode as the last node curr->next = newNode; } }
16

appendNode(int value) appendNode(2.5)

head = new Node;

Head

newNode = new Node; newNode->data = value; newNode->next = NULL;

17

Making first node as head
The next statement to execute is the following if statement. if (!head) head = newNode;

There are no more statements to execute

18

Append another node with the value 7.9. appendNode(7.9)
Once again, the first three statements in the function create a new node, store the argument in the node's data member, and assign its next pointer to NULL. newNode = new Node; newNode->data = value; newNode->next = NULL;

19

Since head no longer points to NULL, the else part of the if statement executes: else // Otherwise, insert newNode at end { // Initialize nodePtr to head of list curr = head; // Find the last node in the list while (curr->next) curr = curr->next; // Insert newNode as the last node curr->next = newNode; }

curr

curr

Append another node with the value 12.6. appendNode(12.6)

The third time appendNode is called, 12.6 is passed as the argument. Once again, the first three statements create a node with the argument stored in the value member. newNode = new Node; newNode->data = value; newNode->next = NULL;

21

Since head no longer points to NULL, the else part of the if statement executes: else // Otherwise, insert newNode at end { // Initialize nodePtr to head of list curr = head; // Find the last node in the list while (curr->next) curr = curr->next; // Insert newNode as the last node curr->next = newNode; }

curr curr

The while loop's conditional test will fail after the first iteration because curr->next now points to NULL. The last statement, curr->next = newNode; causes curr->next to point to the new node. This inserts newNode at the end of the list

curr

The figure above depicts the final state of the linked list.
23

Preliminaries

Figure 4.1 a) A linked list of integers; b) insertion; c) deletion
© 2005 Pearson Addison-Wesley. All rights reserved 4-24

Traversing or Displaying the List

• The displayList member function traverses the list, displaying the value member of each node. The following pseudocode represents the algorithm. The C++ code for the member function follows on the next slide.
Assign List head to node curr While curr is not NULL Display the value member of the curr. Assign curr to its own next member. End While.

25

displayList(void)
Void displayList(void) { Node *curr; curr = head; while (curr!=NULL) { cout value next; }

}

26

Inserting a Node

• Using the listNode structure again, the pseudocode on the next slide shows an algorithm for finding a new node’s proper position in the list and inserting there. • The algorithm assumes the nodes in the list are already in order.

27

Create a new node. Store data in the new node. If there are no nodes in the list Make the new node the first node. Else Find the first node whose value is greater than or equal the new value, or the end of the list (whichever is first). Insert the new node before the found node, or at the end of the list if no node was found. End If.

28

The code for the traversal algorithm is shown below. (As before, num holds the value being inserted into the list.)
// Initialize curr to head of list curr = head;
// Skip all nodes whose value member is less // than num. while (curr != NULL && curr->data < value) { previousNode = curr; curr = curr->next; }

The entire insertNode function begins on the next slide.

29

Inserting a Node into a Specified Position of a Linked List
• To insert a node between two nodes newPtr->next = cur; prev->next = newPtr;

Figure 4.12 Inserting a new node into a linked list

© 2005 Pearson Addison-Wesley. All rights reserved

4-30

Inserting a Node into a Specified Position of a Linked List
• To insert a node at the beginning of a linked list newPtr->next = head; head = newPtr;

Figure 4.13

Inserting at the beginning of a linked list

© 2005 Pearson Addison-Wesley. All rights reserved

4-31

Inserting a Node into a Specified Position of a Linked List
• Inserting at the end of a linked list is not a special case if cur is NULL newPtr->next = cur; prev->next = newPtr;

Inserting at the end of a linked list

Void insertNode(float vlaue)
{ Node *newNode, *curr, *previous; // Allocate a new node & store Num newNode = new Node; newNode->data = value; // If there are no nodes in the list // make newNode the first node if (head==NULL) { head = newNode; newNode->next = NULL; } else // Otherwise, insert newNode. { // Initialize nodePtr to head of list curr = head; // Skip all nodes whose value member is less than value. while (curr != NULL && curr->data < value) { previousNode = curr; curr = curr->next; }

Continued from previous slide.

// If the new mode is to be the 1st in the list, // insert it before all other nodes. if (previous == NULL) { head = newNode; newNode-> = curr;

} else { previous->next = newNode; newNode->next = curr; } } }

InsertNode with the value 10.5 curr a new node is created and the function argument is copied to its data member. Since the list already has nodes stored in it, the else part of the if statement will execute. It begins by assigning nodePtr to head.

Since curr is not NULL and curr->data is less than value, the while loop will iterate. During the iteration, previous will be made to point to the node that curr is pointing to. curr will then be advanced to point to the next node. curr while (curr != NULL && curr->data < value) { previousNode = curr; curr = curr->next; }

Once again, the loop performs its test. Since curr is not NULL and curr->data is less than value, the loop will iterate a second time. During the second iteration, both previousNode and curr are advanced by one node in the list. curr while (curr != NULL && curr->data < value) { previousNode = curr; curr = curr->next; 37 }

This time, the loop's test will fail because curr is not less than value. The statements after the loop will execute, which cause previousNode->next to point to newNode, and newNode->next to point to curr. curr If you follow the links, from the head pointer to the NULL, you will see that the nodes are stored in the order of their value members.
38

Deleting a Node

• Deleting a node from a linked list requires two steps:
– Remove the node from the list without breaking the links created by the next pointers – Deleting the node from memory

• The deleteNode function begins on the next slide.

39

Void deleteNode(float value) { ListNode *curr, *previousNode; // If the list is empty, do nothing. if (!head) return; // Determine if the first node is the one. if (head->data == value) { curr = head->next; delete head; head = curr; }

Continued on next slide…
40

Continued from previous slide. else { // Initialize nodePtr to head of list curr = head;

// Skip all nodes whose value member is // not equal to num. while (curr != NULL && curr->data != value) { previousNode = curr; curr = curr->next; }
// Link the previous node to the node after // nodePtr, then delete nodePtr. previousNode->next = curr->next; delete curr; } }
41

Deleting a Specified Node from a Linked List

Deleting a node from a linked list

Deleting the first node
4-42

Look at the else part of the second if statement. This is where the function will perform its action since the list is not empty, and the first node does not contain the value 7.9. Just like insertNode, this function uses curr and previousNode to traverse the list. The while loop terminates when the value 7.9 is located. At this point, the list and the other pointers will be in the state depicted in the figure below.

43

next, the following statement executes.

previousNode->next = curr->next;
The statement above causes the links in the list to bypass the node that curr points to. Although the node still exists in memory, this removes it from the list.

The last statement uses the delete operator to complete the total deletion of the node. 44

Variations of Linked Lists
• Circular linked lists
– The last node points to the first node of the list
A Head B C

– How do we know when we have finished traversing the list? (Tip: check if the pointer of the current node is equal to the head.)

Variations of Linked Lists
• Doubly linked lists
– Each node points to not only successor but the predecessor – There are two NULL: at the first and last nodes in the list – Advantage: given a node, it is easy to visit its predecessor. Convenient to traverse lists backwards
 A B C 

Head

Array versus Linked Lists

• Linked lists are more complex to code and manage than arrays, but they have some distinct advantages.
– Dynamic: a linked list can easily grow and shrink in size.
• We don’t need to know how many nodes will be in the list. They are created in memory as needed. • In contrast, the size of a C++ array is fixed at compilation time.

– Easy and fast insertions and deletions
• To insert or delete an element in an array, we need to copy to temporary variables to make room for new elements or close the gap caused by deleted elements. • With a linked list, no need to move other nodes. Only need to reset some pointers.

Comparing Array-Based and Pointer-Based Implementations
• Size
– Increasing the size of a resizable array can waste storage and time

• Storage requirements
– Array-based implementations require less memory than a pointer-based ones

4-48

Comparing Array-Based and Pointer-Based Implementations
• Access time
– Array-based: constant access time – Pointer-based: the time to access the ith node depends on i

• Insertion and deletions
– Array-based: require shifting of data – Pointer-based: require a list traversal

4-49

Doubly Linked Lists
• To delete the node to which cur points
(cur->precede)->next = cur->next; (cur->next)->precede = cur->precede;

• To insert a new node pointed to by newPtr before the node pointed to by cur newPtr->next = cur; newPtr->precede = cur->precede; cur->precede = newPtr; newPtr->precede->next = newPtr;

4-50

Application: Maintaining an Inventory
• Operations on the inventory
– List the inventory in alphabetical order by title (L command) – Find the inventory item associated with title (I, M, D, O, and S commands) – Replace the inventory item associated with a title (M, D, R, and S commands) – Insert new inventory items (A and D commands)
© 2005 Pearson Addison-Wesley. All rights reserved 4-51

Similar Documents

Free Essay

C++ Linkedlist Problems

...Linked List Problems By Nick Parlante Copyright ©1998-2002, Nick Parlante Abstract This document reviews basic linked list code techniques and then works through 18 linked list problems covering a wide range of difficulty. Most obviously, these problems are a way to learn about linked lists. More importantly, these problems are a way to develop your ability with complex pointer algorithms. Even though modern languages and tools have made linked lists pretty unimportant for day-to-day programming, the skills for complex pointer algorithms are very important, and linked lists are an excellent way to develop those skills. The problems use the C language syntax, so they require a basic understanding of C and its pointer syntax. The emphasis is on the important concepts of pointer manipulation and linked list algorithms rather than the features of the C language. For some of the problems we present multiple solutions, such as iteration vs. recursion, dummy node vs. local reference. The specific problems are, in rough order of difficulty: Count, GetNth, DeleteList, Pop, InsertNth, SortedInsert, InsertSort, Append, FrontBackSplit, RemoveDuplicates, MoveNode, AlternatingSplit, ShuffleMerge, SortedMerge, SortedIntersect, Reverse, and RecursiveReverse. Contents Section 1 — Review of basic linked list code techniques Section 2 — 18 list problems in increasing order of difficulty Section 3 — Solutions to all the problems 3 10 20 This is document #105, Linked List Problems, in the...

Words: 7907 - Pages: 32

Free Essay

Dont Have Papers Yet

...A linked list is made up of a series of objects, called the nodes of the list. Because a list node is a distinct object. Linked lists are among the simplest and most common data structures. The principal benefit of a linked list over a conventional array is that the list elements can easily be inserted or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory or on disk, while an array has to be declared in the source code, before compiling and running the program. Linked lists allow insertion and removal of nodes at any point in the list, and can do so with a constant number of operations if the link previous to the link being added or removed is maintained during list traversal. Singly Linked List: Singly linked lists contain nodes which have a data field as well as a next field, which points to the next node in line of nodes. Operations that can be performed on singly linked lists include insertion, deletion and traversal. Finding and Deleting Specified Link: Finding algorithm Beginning from the head, 1. Check, if the end of a list hasn't been reached yet; 2. Do some actions with the current node, which is specific for particular algorithm; 3. Current node becomes previous and next node becomes current. Deleting 4. Save reference to link 5. Delete it, save first to old next 6. Return deleted link Operation on Singly Link List: * Search * Insert ...

Words: 818 - Pages: 4

Free Essay

Non Linear Data Structure

...data in the list.As said earlier a pointer to the next data. example of a linked list: class node{// all nodes will be the objects of this class public int data; public link next_node;//a pointer to next data } public node(int data){ this.data=data; }//end of constructor public void showdata(){ System.out.println("data= "+data); } }//end of class node After defining class for each node we need to define a class for link list. Link list contains a pointer to the first node in the list,Which should be initialized to null in the beginning. All the operations to be performed on the link list is defined as functions in this class. For example insert first,Delete,insert search etc. class linkedlist{ private node first_node;//pointer to the first node is defined public linkedlist(){ first_node=null; } public void add_DAta(int data1){ //create...

Words: 475 - Pages: 2

Free Essay

Mfrkkwl

...An array is defined as a sequence of objects of the same data type. All the elements of an array are either of type int (whole numbers), or all of them are of type char, or all of them are of floating decimal point type, etc. An array cannot have a mixture of different data types as its elements. Also, array elements cannot be functions; however, they may be pointers to functions. In computer memory, array elements are stored in a sequence of adjacent memory blocks. Since all the elements of an array are of same data type, the memory blocks allocated to elements of an array are also of same size. Each element of an array occupies one block of memory. The size of memory blocks allocated depends on the data type and it is same as for different data types. Often, we have to deal with groups of objects of same type such as names of persons, instrument readings in an experiment, roll numbers of students, and so on. These groups can be conveniently represented as elements of arrays. The declaration of array includes the type of array that is the type of value we are going to store in it, the array name and maximum number of elements. Examples: short val[200]; val[12] = 5;   Declaration & Data Types Arrays have the same data types as variables, i.e., short, long, float etc. They are similar to variables: they can either be declared global or local. They are declared by the given syntax: Datatype array_name [dimensions] = {element1,element2,….,element} The declaration form...

Words: 7409 - Pages: 30

Free Essay

Stat

...what is generics in jdk1.5? | | |Answer |Hi, | | |# 1 | | | | |Generics is Template support added in JDK1.5 where in we can maintain templates of object with particular type and | | | |also this object is restricted to accept type other than specified one at code time. | | | |This help reducing runtime exception and also we can create predefined well formed templates of Type. | | | | | | | |Best Example. | | | | | | | |http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#generics | | | | | | | |Code written to use the generics feature should not be a lot slower or a lot more memory-intensive than non-generic | | | ...

Words: 1669 - Pages: 7

Free Essay

Competency Matrix

...Computer Science 2n (Level 0) n2 (Level 1) n (Level 2) log(n) (Level 3) data structures Doesn’t know the difference between Array and LinkedList Able to explain and use Arrays, LinkedLists, Dictionaries etc in practical programming tasks Knows space and time tradeoffs of the basic data structures, Arrays vs LinkedLists, Able to explain how hashtables can be implemented and can handle collisions, Priority queues and ways to implement them etc. Knowledge of advanced data structures like B-trees, binomial and fibonacci heaps, AVL/Red Black trees, Splay Trees, Skip Lists, tries etc. algorithms Unable to find the average of numbers in an array (It’s hard to believe but I’ve interviewed such candidates) Basic sorting, searching and data structure traversal and retrieval algorithms Tree, Graph, simple greedy and divide and conquer algorithms, is able to understand the relevance of the levels of this matrix. systems programming Doesn’t know what a compiler, linker or interpreter is Basic understanding of compilers, linker and interpreters. Understands Understands kernel mode vs. user mode, multi-threading, synchronization primitives and how they’re implemented, able to read what assembly code is and how things work at the hardware level. Some assembly code. Understands how networks work, understanding of network protocols and socket level programming. knowledge of virtual memory and paging. Able to recognize and code dynamic...

Words: 1812 - Pages: 8

Premium Essay

Arraylist, Hashmap, Queue Student Assignment

...return (getName() + "'s average grade is " + pattern.format(getComputeAverage())); } } ------------------------ import java.io.FileReader; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; import java.util.Set; import java.util.StringTokenizer; public class Test { public static void main(String[] args) { String inputFileName = "data.txt"; FileReader fileReader = null; // Create the FileReader object try { fileReader = new FileReader(inputFileName); } catch (FileNotFoundException e) { e.printStackTrace(); } Queue studentQueue = new LinkedList(); HashMap studentMap = new HashMap();...

Words: 366 - Pages: 2

Free Essay

Java

...limits. c) Write a program to implement below diamond pattern. * *** ***** d) Write a program to implement string concatenation, finding string length, find sub string and check the given string is palindrome or not? e) Write a program to implement constructor overloading by passing different number of parameter of different types. f) Write a program to find area of Square and rectangle figures using method. g) Write a program to calculate bonus for different departments using method overriding. h) Write a program to perform the different arithmetic operation show the exception handling. i) Write a program to implement thread priorities. j) Write a program to create a linked list using LinkedList class of Collection Framework k) Write a program, to create a Frame Window in an applet. l) Write a program to create simple student registration using applet, read the input using text boxes and display the output once user click on the button. m) Write a program to draw different polygon by using AWT supported Graphics method n) Write a program to implement the appropriate interface in the key listener so that it will receive the type of event. ASSIGNMENT EXCEPTION Exception and exception handling -introduction, types of errors, exceptions, syntax of exception, handling codes Cover Page S.No | Program Title | Date of Completion | Page No | Lecturer Signature | 1. | To find HCF of two number reading inputs as...

Words: 275 - Pages: 2

Free Essay

Functional Application and Minimization of Booleanfunction Using Gates, K-Map & Quine-Mccluskey

...Vol 3 Issue 2 March 2013 Impact Factor : 0.2105 ORIGINAL ARTICLE ISSN No : 2230-7850 Monthly Multidisciplinary Research Journal Indian Streams Research Journal Executive Editor Ashok Yakkaldevi Editor-in-chief H.N.Jagtap IMPACT FACTOR : 0.2105 Welcome to ISRJ RNI MAHMUL/2011/38595 ISSN No.2230-7850 Indian Streams Research Journal is a multidisciplinary research journal, published monthly in English, Hindi & Marathi Language. All research papers submitted to the journal will be double - blind peer reviewed referred by members of the editorial Board readers will include investigator in universities, research institutes government and industry with research interest in the general subjects. International Advisory Board Flávio de São Pedro Filho Federal University of Rondonia, Brazil Hasan Baktir Mohammad Hailat English Language and Literature Dept. of Mathmatical Sciences, University of South Carolina Aiken, Aiken SC Department, Kayseri Kamani Perera 29801 Regional Centre For Strategic Studies, Sri Ghayoor Abbas Chotana Lanka Department of Chemistry, Lahore Abdullah Sabbagh University of Management Sciences [ PK Engineering Studies, Sydney Janaki Sinnasamy ] Librarian, University of Malaya [ Anna Maria Constantinovici Catalina Neculai Malaysia ] AL. I. Cuza University, Romania University of Coventry, UK Romona Mihaila Spiru Haret University, Romania Delia Serbescu Spiru Haret University, Bucharest, Romania Anurag Misra DBS College, Kanpur Titus Pop Ecaterina...

Words: 7048 - Pages: 29

Premium Essay

Java

...JMaster list of Java interview questions - 115 questions By admin | July 18, 2005 115 questions total, not for the weak. Covers everything from basics to JDBC connectivity, AWT and JSP. 1. What is the difference between procedural and object-oriented programs?- a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code. b) In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code. 2. What are Encapsulation, Inheritance and Polymorphism?- Encapsulation is the mechanism that binds together code and data it manipulates and keeps both safe from outside interference and misuse. Inheritance is the process by which one object acquires the properties of another object. Polymorphism is the feature that allows one interface to be used for general class actions. 3. What is the difference between Assignment and Initialization?- Assignment can be done as many times as desired whereas initialization can be done only once. 4. What is OOPs?- Object oriented programming organizes a program around its data, i. e. , objects and a set of well defined interfaces to that data. An object-oriented program can be characterized as data controlling 5. access to code. What are Class, Constructor...

Words: 6762 - Pages: 28

Free Essay

Gdhdgfrdes

...Faculty of Computer Studies M180 Data Structures and Algorithms in Java Mid-Term Assessment (MTA) Fall – 2013 Saturday 17, November 2012 Number of MTA Pages: (including this cover sheet) ( 3 ) Time Allowed: ( 2 ) Hour Instructions: 1- Write all your answers on the same exam paper. 2- Electronic devices (especially calculators) are not allowed. Question Type Max. Mark Part 1: Multiple Choice Questions 10 Part 2: Short questions 20 Part 3: Coding questions 30 Total 60 Student Mark M180 Midterm-Ex am Fall 2012-2013 PART 1: ALL QUESTIONS ARE REQUIRED [10 Marks] Question 1: Choose the correct answer: (10 marks, one mark each) 1) a) b) c) d) One of the following methods return the top of the stack without applying any modifications: pop( ) push( ) peek( ) isEmpty( ) 2) a) b) c) d) Two main measures for the efficiency of an algorithm are: Processor and memory Time and space Complexity and capacity Data and space 3) a) b) c) d) A doubly nested “for loop” typically takes time in: Θ(n2) Θ(n) Θ(log n) Θ(log n2) 4) a) b) c) d) Arrays are best data structures: For relatively permanent collections of data For the size of the structure and the data in the structure are constantly changing For both of above situation For none of above situation 5) The elements of an array are stored successively in memory cells because: a) The architecture of computer memory does not allow...

Words: 1212 - Pages: 5

Free Essay

Lol Girl

...Blue Pelican Java by Charles E. Cook Version 3.0.5h Copyright © 2004 - 2008 by Charles E. Cook; Refugio, Tx (All rights reserved) 1-1 “Blue Pelican Java,” by Charles E. Cook. ISBN 1-58939-758-4. Published 2005 by Virtualbookworm.com Publishing Inc., P.O. Box 9949, College Station, Tx 77842, US. ©2005, Charles E. Cook. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, recording or otherwise, without the prior written permission of Charles E. Cook. Manufactured in the United States of America. Preface You will find this book to be somewhat unusual. Most computer science texts will begin with a section on the history of computers and then with a flurry of definitions that are just “so many words” to the average student. My approach with Blue Pelican Java is to first give the student some experience upon which to hang the definitions that come later, and consequently, make them more meaningful. This book does have a history section in Appendix S and plenty of definitions later when the student is ready for them. If you will look at Lesson 1, you will see that we go right to work and write a program the very first day. The student will not understand several things about that first program, yet he can immediately make the computer do something useful. This work ethic is typical of the remainder of the book. Rest assured that full understanding...

Words: 31284 - Pages: 126

Free Essay

Exercise Java

...Programming Exercises For Chapter 2 -------------------------------------------------------------------------------- THIS PAGE CONTAINS programming exercises based on material from Chapter 2 of this on-line Java textbook. Each exercise has a link to a discussion of one possible solution of that exercise. http://www.java2s.clanteam.com -------------------------------------------------------------------------------- Exercise 2.1: Write a program that will print your initials to standard output in letters that are nine lines tall. Each big letter should be made up of a bunch of *'s. For example, if your initials were "DJE", then the output would look something like: ****** ************* ********** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ******** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ***** **** ********** See the solution! : visit this website http://java2s.clanteam.com/ -------------------------------------------------------------------------------- Exercise 2.2: Write a program that simulates rolling a pair of dice. You can simulate rolling one die by choosing one of the integers 1, 2...

Words: 18137 - Pages: 73

Free Essay

Android Based Webstatic Server

...A Project Report On ANDROID BASED STATIC WEBSERVER BY CONTENTS TITLE ABSTRACT INTRODUCTION…………………………………………………. 1 Purpose……………………………………………………..………… 1.1 Scope…………………………………………………..…….……….. 1.2 Definitions, Acroynms, Abbrivations……………………. 1.3 Overview……………………..………………………………………. 1.4 SYSTEM ANALYSIS……………………………………… 3 Software Requirements Specification…..………………. 3.1 Hardware Requirements……………………………………….. 3.1.1 Software Requirements………………………………………… 3.1.2 IMPLEMENTATION……………………………………… 4 Modules……………………………………………………………….. 4.1 Accounts…………………………………………………………..4.1.1 Transactions………………………………………………………….. 4.1.2 DESIGN………………..…………………………….……… 5 UML Diagrams………………………………………………………… 5.1 Class Diagram………………………………………………………… 5.1.1 Usecase Diagram….……………………………………………….. 5.1.2 Sequence Diagram….……………………………………………….. 5.1.3 RESULT FOR IMPLEMENTATION…………………… 6 Output Screens………………………………………………………. 6.1 SYSTEM TESTING………………………………………….7 Types of Testing………………………………………………………. 7.1 TESTCASES…………………………………………………..8 CONCLUSION………………………………………………..9 ANDROID BASED STATIC WEBSERVER ABSTRACT Android is software platform and operating system for mobile devices. Being an open-source, it is based on the Linux kernel. It was developed by Google and later the Open Handset Alliance (OHA). It allows writing managed code in the Java language. Due to Android here is the...

Words: 9090 - Pages: 37

Free Essay

Java Programming

...A Programmer’s Guide to Java™ SCJP Certification Third Edition This page intentionally left blank A Programmer’s Guide to Java™ SCJP Certification A Comprehensive Primer Third Edition Khalid A. Mughal Rolf W. Rasmussen Upper Saddle River, New Jersey • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sidney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United...

Words: 15086 - Pages: 61