Monday, January 27, 2020

Role Of Data Structures In Programming Languages

Role Of Data Structures In Programming Languages In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. It is also known as the logical or mathematical model of a particular organization of data. Data structures are generally based on the ability of a computer to fetch and store data at any place in its memory, specified by an address a bit string that can be itself stored in memory and manipulated by the program. Thus the record and array data structures are based on computing the addresses of data items with arithmetic operations; while the linked data structures are based on storing addresses of data items within the structure itself. Many data structures use both principles, sometimes combined in non-trivial ways Choice of particular data model depends on 2 considerations:- It must be rich enough in structure to mirror the actual relationships of the data in real world. Structure should be simple enough that one can effectively process the data when necessary. Classification of data structure Primitive and Non-primitive : primitive data structures are basic data structure and are directly operated upon machine instructions.Example Integer,character. Non-primitive data structures are derived data structure from the primitive data structures.Example Structure,union,array. Homogeneous and heterogeneous : In homogeneous data structures all the elements will be of same type.Example array. In heterogeneous data structure the elements are of different types.Example structure. Static and Dynamic data structures :In some data structures memory is allocated at the time of compilation such data structures are known as static data structures . If the allocation of memory is at run-time then such data structures are known as Dynamic data structures.Functions such as malloc, calloc,etc.. are used for run-time memory allocation. Linear and Non-linear data structures : Linear data structure maintain a linear relationship between its elements and whose elements form a sequence and every element in structure has unique predecessor and successor. Example array. Non-linear data structures does not maintain hierarichal relationship between the elements. Example tree Some Data Structures And Their role in Programming Languages Stack In computer science, a stack is a last in, first out (LIFO) data structure. History The stack was first proposed in 1955, and then patented in 1957, by the German Friedrich L. Bauer. The same concept was developed independently, at around the same time, by the Australian Charles Leonard Hamblin.. Operations on stacks A stack can have any abstract data type as an element, but is characterized by only two fundamental operations: push and pop. The push operation adds to the top of the list, hiding any items already on the stack, or initializing the stack if it is empty. The pop operation removes an item from the top of the list, and returns this value to the caller. A pop either reveals previously concealed items, or results in an empty list. Simple representation of a stack A stack is a restricted data structure, because only a small number of operations are performed on it. The nature of the pop and push operations also means that stack elements have a natural order. Elements are removed from the stack in the reverse order to the order of their addition: therefore, the lower elements are typically those that have been in the list the longest. In modern computer languages, the stack is usually implemented with more operations than just push and pop. Some implementations have a function which returns the current length of the stack. Another typical helper operation top (also known as peek) can return the current top element of the stack without removing it. Basic architecture of a stack Role of stacks in programming languages Languages such as Adobe PostScript are also designed around language-defined stacks that are directly visible to and manipulated by the programmer. C++s Standard Template Library provides a stack templated class which is restricted to only push/pop operations. Javas library contains a stack class that is a specialization of vectorthis could be considered a design flaw, since the inherited get() method from vector ignores the LIFO constraint of the stack. The simple model provided in a stack-oriented programming language allows expressions and programs to be interpreted simply and theoretically evaluated much more quickly, since no syntax analysis needs to be done, only lexical analysis. The way programs are written lends itself well to being interpreted by machines, which is why PostScript suits printers well for its use. However, the slightly artificial way of writing PostScript programs can result in an initial barrier to understanding the PostScript language and other stack-oriented programming languages. Whilst the capability of shadowing by overriding inbuilt and other definitions can make things difficult to debug and irresponsible usage of this feature can result in unpredictable behaviour it can make certain functionality much simpler. For example, in PostScript usage, the showpage operator can be overridden with a custom one that applies a certain style to the page, instead of having to define a custom operator or to repeat code to generate the style. Implementation In most high level languages, a stack can be easily implemented through an array. What identifies the data structure as a stack in either case is not the implementation but the interface: the user is only allowed to pop or push items onto the array or linked list, with few other helper operations. The following will demonstrate both implementations, using C. Array The array implementation aims to create an array where the first element (usually at the zero-offset) is the bottom. That is, array[0] is the first element pushed onto the stack and the last element popped off. The program must keep track of the size, or the length of the stack. The stack itself can therefore be effectively implemented as a two-element structure in C: typedef struct { int size; int items[STACKSIZE]; } STACK; The push() operation is used both to initialize the stack, and to store values to it. It is responsible for inserting (copying) the value into the ps->items[] array and for incrementing the element counter (ps->size). In a responsible C implementation, it is also necessary to check whether the array is already full to prevent an overrun. void push(STACK *ps, int x) { if (ps->size == STACKSIZE) { fputs(Error: stack overflown, stderr); abort(); } else ps->items[ps->size++] = x; } The pop() operation is responsible for removing a value from the stack, and decrementing the value of ps->size. A responsible C implementation will also need to check that the array is not already empty. int pop(STACK *ps) { if (ps->size == 0){ fputs(Error: stack underflown, stderr); abort(); } else return ps->items[ps->size]; } Procedures A procedure in a stack-based programming language is treated as a data object in its own right. In PostScript, procedures are denoted between { and }. For example, in PostScript syntax, { dup mul } represents an anonymous procedure to duplicate what is on the top of the stack and then multiply the result a squaring procedure. Since procedures are treated as simple data objects, we can define names with procedures, and when they are retrieved, they are executed directly. Dictionaries provide a means of controlling scoping, as well as storing of definitions. Since data objects are stored in the top-most dictionary, an unexpected capability arises quite naturally: when looking up a definition from a dictionary, the topmost dictionary is checked, then the next, and so on. If we define a procedure that has the same name as another already defined in a different dictionary, the local one will be called. Anatomy of some typical procedures Procedures often take arguments. They are handled by the procedure in a very specific way, different from that of other programming languages. Let us examine a Fibonacci number program in PostScript: /fib { dup dup 1 eq exch 0 eq or not { dup 1 sub fib exch 2 sub fib add } if } def We use a recursive definition, and do so on the stack. The Fibonacci number function takes one argument. We first test whether it is 1 or 0. Let us decompose each of the programs key steps, reflecting the stack. Assume we calculate F(4). stack: 4 dup stack: 4 4 dup stack: 4 4 4 1 eq stack: false 4 4 exch stack: 4 false 4 0 eq stack: false false 4 or stack: false 4 not stack: true 4 Since the expression evaluates to true, the inner procedure is evaluated. stack: 4 dup stack: 4 4 1 sub stack: 3 4 fib (we recurse here) stack: F(3) 4 exch stack: 4 F(3) 2 sub stack: 2 F(3) fib (we recurse here) stack: F(2) F(3) add stack: F(2)+F(3) which is the result we wanted. This procedure does not use named variables, purely the stack. We can create named variables by using the /a exch def construct. For example, {/n exch def n n mul} is a square procedure with a named variable n. Assume that /sq {/n exch def n n mul} def and 3 sq is called. Let us analyse this procedure. stack: 3 /n exch stack: /n 3 def stack: empty (it has been defined) n stack: 3 n stack: 3 3 mul stack: 9 which is the result we wanted. Expression evaluation and syntax parsing Calculators employing reverse Polish notation use a stack structure to hold values. Expressions can be represented in prefix, postfix or infix notations. Conversion from one form of the expression to another form may be accomplished using a stack. Many compilers use a stack for parsing the syntax of expressions, program blocks etc. before translating into low level code. Most of the programming languages are context free languages allowing them to be parsed with stack based machines. Example in C #include int main() { int a[100], i; printf(To pop enter -1n); for(i = 0;;) { printf(Push ); scanf(%d, a[i]); if(a[i] == -1) { if(i == 0) { printf(Underflown); } else { printf(pop = %dn, a[i]); } } else { i++; } } } Runtime memory management A number of programming languages are stack oriented, meaning they define most basic operations (adding two numbers, printing a character) as taking their arguments from the stack, and placing any return values back on the stack. For example, Postscript has a return stack and an operand stack, and also has a graphics state stack and a dictionary stack. Forth uses two stacks, one for argument passing and one for subroutine return addresses. The use of a return stack is extremely commonplace, but the somewhat unusual use of an argument stack for a human-readable programming language is the reason Forth is referred to as a stack based language. Almost all computer runtime memory environments use a special stack (the call stack) to hold information about procedure/function calling and nesting in order to switch to the context of the called function and restore to the caller function when the calling finishes. They follow a runtime protocol between caller and callee to save arguments and return value on the stack. Stacks are an important way of supporting nested or recursive function calls. This type of stack is used implicitly by the compiler to support CALL and RETURN statements (or their equivalents) and is not manipulated directly by the programmer. Some programming languages use the stack to store data that is local to a procedure. Space for local data items is allocated from the stack when the procedure is entered, and is deallocated when the procedure exits. The C programming language is typically implemented in this way. Using the same stack for both data and procedure calls has important security implications (see below) of which a programmer must be aware in order to avoid introducing serious security bugs into a program. Linked Lists In computer science, a linked list is a data structure that consists of a sequence of data records such that in each record there is a field that contains a reference(i.e., a link) to the next record in the sequence. A linked list whose nodes contain two fields: an integer value and a link to the next node Linked lists can be implemented in most languages. Languages such as Lisp and Scheme have the data structure built in, along with operations to access the linked list. Procedural languages, such as C, or object-oriented languages, such as C++ and JAVA, typically rely on mutable references to create linked lists. History Linked lists were developed in 1955-56 by Allen Newell, Cliff Shaw and Herbert Simon at RAND Corporation as the primary data structure for their Information Processing Language. Role of linked lists in programming languages Many programming languages such as Lisp and Scheme have singly linked lists built in. In many functional languages. In languages that support Abstract Data types or templates, linked list ADTs or templates are available for building linked lists. In other languages, linked lists are typically built using references together with records. Here is a complete example in C: #include /* for printf */ #include /* for malloc */ typedef struct node { int data; struct node *next; /* pointer to next element in list */ } LLIST; LLIST *list_add(LLIST **p, int i); void list_remove(LLIST **p); LLIST **list_search(LLIST **n, int i); void list_print(LLIST *n); LLIST *list_add(LLIST **p, int i) { if (p == NULL) return NULL; LLIST *n = malloc(sizeof(LLIST)); if (n == NULL) return NULL; n->next = *p; /* the previous element (*p) now becomes the next element */ *p = n; /* add new empty element to the front (head) of the list */ n->data = i; return *p; } void list_remove(LLIST **p) /* remove head */ { if (p != NULL *p != NULL) { LLIST *n = *p; *p = (*p)->next; free(n); } } LLIST **list_search(LLIST **n, int i) { if (n == NULL) return NULL; while (*n != NULL) { if ((*n)->data == i) { return n; } n = (*n)->next; } return NULL; } void list_print(LLIST *n) { if (n == NULL) { printf(list is emptyn); } while (n != NULL) { printf(print %p %p %dn, n, n->next, n->data); n = n->next; } } int main(void) { LLIST *n = NULL; list_add(n, 0); /* list: 0 */ list_add(n, 1); /* list: 1 0 */ list_add(n, 2); /* list: 2 1 0 */ list_add(n, 3); /* list: 3 2 1 0 */ list_add(n, 4); /* list: 4 3 2 1 0 */ list_print(n); list_remove(n); /* remove first (4) */ list_remove(n->next); /* remove new second (2) */ list_remove(list_search(n, 1)); /* remove cell containing 1 (first) */ list_remove(n->next); /* remove second to last node (0) */ list_remove(n); /* remove last (3) */ list_print(n); return 0; Queue A queue is a particular kind of collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position and removal of entities from the front terminal position. This makes the queue a First In First Out. In a FIFO data structure, the first element added to the queue will be the first one to be removed. This is equivalent to the requirement that whenever an element is added, all elements that were added before have to be removed before the new element can be invoked. A queue is an example of a linear data structure. Representation of a Queue Example C Program #include int main(){ int a[100],i,j; printf(To DQueue Enter -1n); for(i=0;;){ printf(NQueue ); scanf(%d,a[i]); if(a[i]==0) break; if(a[i]==-1){ a[i]=0; if(i==0){ printf(Wrongn); continue; } printf(DQueue = %dn,a[0]); for(j=0;j a[j]=a[j+1]; i; } else i++; } for(j=0;j printf(%d ,a[j]); return 0; }

Sunday, January 19, 2020

Between Wishes and Beliefs in Wild Grapes Essay -- Wild Grapes Essays

Between Wishes and Beliefs in Wild Grapes      Ã‚  Ã‚  Ã‚  Ã‚   In "Wild Grapes," Robert Frost demonstrates the complex thoughts and struggles of a woman who lives her life, wishing that she had gained a knowledge that would have made her life different. At the same time, she hopes to preserve the exhilarating way she lives her life. Through the use of character portrayal, metaphor, symbolism, and diction, Robert Frost suggests to the reader that although people know that they should prepare themselves to walk through life, they still listen to their hearts, which causes them to be unprepared for what lies ahead of them. The poem starts with the woman telling a story from her youth, which is engraved traumatically in her mind.    The story that the woman describes is about an incident that happens when her brother takes her to a glade where there is a grape tree standing alone. Her brother starts to climb the tree while she admires the tree filled with the grapes. Climbing even higher and picking some grapes to eat, he bends the tree to try to let her have some. As she picks her own grapes, he tells her to hold the top of the tree. So she holds the tree as she was told. The tree, however, catches and suspends her, and it keeps her there for a minute with its grapes. She starts to cry like a baby and does not know what to do. But she clings to the tree, even though her brother is telling her to let go. Trying to bend the tree down, her brother tells her to wait until he leads her down. Finally, against his advice she falls off the tree and feels the ground with her feet. Since the incident happened, the life that she has been living is something different than what she expects or what people expect . She knows sh... ...o her struggles that are engraved traumatically in her mind.    Robert Frost amazingly demonstrates the woman's complex thoughts through the use of character portrayal, metaphor, symbolism, and diction. He illustrates his clear idea about how she lives her life, having struggles in her mind. Reflecting her life in the story that she tells, the poem presents a journey to find out how and why she lives the way she lives between her wishes and beliefs. Using those devices effectively, Frost presents his ideas clearly and makes a strong impression on the reader. Through his demonstration of her journey of life, he shows the significance of life and its complexity.    Works Cited    Frost, Robert. (1920, December). "Wild Grape." Harper's Magazine [Online], 3 paragraphs. Available: http:// www.bartleby.com/155/15.html [1999, October 6].   

Saturday, January 11, 2020

Characteristics of Philippine Literature

CHARACTERISTICS OF PHILIPPINE LITERATURE Philippine literature is the literature associated with the Philippines and includes the legends of prehistory, and the colonial legacy of the Philippines. Most of the notable literature of the Philippines was written during the Spanish period and the first half of the 20th century in Spanish language. Philippine literature is written in Spanish, English, Tagalog, and/or other native Philippine languages. Philippine literature refers to all literature from the Philippines, written in Spanish, English, Tagalog, and a variety of other Philippine languages.Philippine literature flourished during the Spanish period (nineteenth century) and the first half of the twentieth century. The literature of the Philippines covers a variety of genres, most notably poetry and metrical romances, prose, dramas, religious dramas, and secular dramas.INTRODUCTION TO PHILIPPINE LITERATUREThe history of a nation can be learned in its constitution, its laws and its political statements. But to know the hist ory of a nation’s spirit, you must read its literature. For in literature you can discover how the people of a nation have reacted to the events around them.In the stories, essays and poems contained in this volume, you will read the dreams, anxieties, joys and problems of the Filipino in the past seventy-five years. By reading this development of Philippine Literature you will review what has happened to the Filipino since 1900. But literature offers much more than a mere personalized history. For an important quality of art is to share with others the intense realization of a human experience. Through this sharing, you may recognize your own experiences. You may learn what you are or how you have become what you are. You may even learn what you might be in the future.Philippine literature shows you how the Filipino differs from others. Yet in a sense the Filipino writer is linked with all the other writers of the world. For in explaining or questioning human experience, wri ters are never alone. Philippine Literature in English is really a part of the literatures of the world. A further quality of literature is that the expressions used should be memorable. The language should be clear and forceful so that the ideas strike the reader with almost the same force with which they struck the writer. The early Filipino writers had difficulty in expressing themselves since English was a language new to them.The marvel is that they learned this language so quickly and with such facility. Philippine literature in English reveals the spirit of the Filipino. Gradually this literature has learned to express the deepest of human experiences in words that create memorable images. You may divide Philippine Literature in English into many types and numerous periods. But for our purposes, we shall consider three stages through which the literature has passed. These stages might be called: 1) The Early Period, from 1900 to 1930 2) The Middle Period, from 1930 to 1960 3) The Modern Period, from 1960 to 1974Philippine literature Philippine literature is the literature associated with the Philippines and includes the legends of prehistory, and the colonial legacy of the Philippines, written in both Indigenous, and Hispanic languages. Most of the notable literature of the Philippines was written during the Spanish period and the first half of the 20th century in Spanish language. Philippine literature is written in Spanish, English, Tagalog, and other native Philippine languages.EARLY WORKSâ€Å"Doctrina Christiana†, Manila, 1593, is the first book printed in the Philippines.Tomas Pinpin wrote and printed in 1610 â€Å"Librong Pagaaralan nang mga Tagalog nang Wikang Kastila†, 119 pages designed to help fellow Filipinos to learn the Spanish language in a simple way. He is also credited with the first news publication made in the Philippines, â€Å"Successos Felices†, CLASSICAL LITERATURE IN SPANISH (19TH CENTURY) On December 1, 184 6, La Esperanza, the first daily newspaper, was published in the country. Other early newspapers were La Estrella (1847), Diario de Manila (1848) and Boletin Oficial de Filipinas (1852). The first provincial newspaper was El Eco de Vigan (1884), which was issued in Ilocos.In Cebu City â€Å"El Boletin de Cebu† (The Bulletin of Cebu), was published in 1890. On 1863, the Spanish government introduced a system of free public education that had an important effect on the ability of the population to read in Spanish and further in the rise of an educated class called the Ilustrado (meaning, well-informed). Spanish became the social language of urban places and the true lingua franca of the archipelago. A good number of Spanish newspapers were published until the end of the 1940s, the most influential of them being El Renacimiento, printed in Manila by members of the Guerrero de Ermita family.Some members of the ilustrado group, while residing or studying in Spain, decided to start a literary production in Spanish with the aim of serving the autonomy and/or independence projects. Members of this group included Pedro Alejandro Paterno, who wrote the novel Ninay (first novel written by a Filipino); the Philippine national hero, Jose Rizal, who wrote excellent poetry and two famous novels in Spanish: Noli Me Tangere (Touch Me Not), and El Filibusterismo'.MODERN LITERATURE (20TH AND 21ST CENTURY)The greatest portion of Spanish literature was written during the American period, most often as an expression of pro-Hispanic nationalism, by those who had been educated in Spanish or had lived in the Spanish-speaking society of the big cities, and whose principles entered in conflict with the American cultural trends. Such period of Spanish literary production—i. e. , between the independence of Spain in 1898 and well ahead into the decade of the 1940s—is known as â€Å"Edad de Oro del Castellano en Filipinas. † Some prominent writers of this era we re Wenceslao Retana and Claro Mayo Recto, both in drama and essay; Antonio M.Abad and Guillermo Gomez Wyndham, in the narrative; Fernando Maria Guerrero and Manuel Bernabe, both in poetry. The predominant literary style was the so called â€Å"Modernismo,† a mixture of elements from the French Parnassien and Symboliste schools, as promoted by some Latin American and Peninsular Spanish writers (e. g. the Nicaraguan Ruben Dario, the Mexican Amado Nervo, the Spaniard Francisco Villaespesa, and the Peruvian Jose Santos Chocano as major models). Apart from the works in Spanish, the only remarkable and valuable Filipino writer writing in the English language is Nick Joaquin.

Friday, January 3, 2020

10 Facts About the Geography of the Pacific Northwest

The Pacific Northwest is the region of the western United States located adjacent to the Pacific Ocean. It runs north to south from British Columbia, Canada, to Oregon. Idaho, parts of Montana, northern California, and southeastern Alaska are also listed as parts of the Pacific Northwest in some accounts. Much of the Pacific Northwest consists of rural forested land; however, there are several large population centers which include Seattle and Tacoma, Washington, Vancouver, British Columbia, and Portland, Oregon. The region of the Pacific Northwest has a long history that was mainly occupied by various Native American groups. Most of these groups are believed to have been engaged in hunting and gathering as well as fishing. Today, there are still visible artifacts from the Pacific Northwests early inhabitants as well as thousands of descendants that still practice historic Native American culture. What to Know About the Pacific Northwest One of the first United States claims to the lands of the Pacific Northwest region came after Lewis and Clark explored the area in the early 1800s.The Pacific Northwest is highly active geologically. The region is dotted with several large active volcanoes in the Cascade Mountain Range. Such volcanoes include such Mount Shasta in northern California, Mount Hood in Oregon, Mount Saint Helens and Rainier in Washington and Mount Garibaldi in British Columbia.There are four mountain ranges dominating the Pacific Northwest. They are the Cascade Range, the Olympic Range, the Coast Range and parts of the Rocky Mountains.Mount Rainier is the highest mountain in the Pacific Northwest at 14,410 feet (4,392 m).The Columbia River, which begins in the Columbia Plateau in western Idaho and flows through the Cascades to the Pacific Ocean, has the second-largest flow of water (behind the Mississippi River) than any other river in the lower 48 states.In general, the Pacific Northwest has a wet and co ol climate which has led to the growth of extensive forests featuring some of the largest trees in the world. The regions coastal forests are considered temperate rainforests. More inland, however, the climate can be drier with more harsh winters and warmer summers.The economy of the Pacific Northwest is varied, but some of the worlds largest and most successful technology companies such as Microsoft, Intel, Expedia, and Amazon.com are located in the region.Aerospace is also an important industry in the Pacific Northwest as Boeing was founded in Seattle and currently  some of its operations  in the Seattle area. Air Canada has a large hub at the Vancouver International Airport.The Pacific Northwest is considered an educational center for both the United States and Canada as large universities such as the University of Washington, the University of Oregon and the University of British Columbia are located there.The dominant ethnic groups of the Pacific Northwest are Caucasian, Me xican and Chinese.