Strings. Our civilization has been built on them but we are moving towards to digital media Anyway, handling digital media is similar to.. A string is.

Slides:



Advertisements
Similar presentations
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Advertisements

C Characters & Strings Character Review Character Handling Library Initialization String Conversion Functions String Handling Library Standard Input/Output.
Strings.
Current Assignments Homework 5 will be available tomorrow and is due on Sunday. Arrays and Pointers Project 2 due tonight by midnight. Exam 2 on Monday.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
Constants and Data Types Constants Data Types Reading for this class: L&L,
Computer Science Basics CS 216 Fall Operating Systems interface to the hardware for the user and programs The two operating systems that you are.
Tools for Text Review. Algorithms The heart of computer science Definition: A finite sequence of instructions with the properties that –Each instruction.
C Strings. The char Data Type for Storing Characters The char data type can is used to declare a variable that can hold a single character. Examples:
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Fundamentals of Strings and Characters Characters.
Chapter 9 Characters and Strings. Topics Character primitives Character Wrapper class More String Methods String Comparison String Buffer String Tokenizer.
Hash Tables1 Part E Hash Tables  
Working with the data type: char  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming.
Hash Tables1 Part E Hash Tables  
Data Representation Kieran Mathieson. Outline Digital constraints Data types Integer Real Character Boolean Memory address.
Characters and Strings. Characters In Java, a char is a primitive type that can hold one single character A character can be: –A letter or digit –A punctuation.
String Escape Sequences
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
Agenda Data Representation – Characters Encoding Schemes ASCII
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
C Programming Lecture 4 : Variables , Data Types
Copyright © 2002 W. A. Tucker1 Chapter 7 Lecture Notes Bill Tucker Austin Community College COSC 1315.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Characters In Java, single characters are represented.
STRINGS & STRING HANDLING FUNCTIONS STRINGS & STRING HANDLING FUNCTIONS.
Chars and strings Jordi Cortadella Department of Computer Science.
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Characters The data type char represents a single character in Java. –Character values are written as a symbol: ‘a’, ‘)’, ‘%’, ‘A’, etc. –A char value.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 3, 09/11/2003 Prof. Roy Levow.
Character Arrays Based on the original work by Dr. Roger deBry Version 1.0.
Primitive Variables.
Sha Tin Methodist College F.4 Computer Studies Pascal Programming.
SE-1010 Dr. Mark L. Hornick 1 Variables & Datatypes.
Agenda ASCII char N int Character class char N String Bitwise operators homework.
Java Programming Java Basics. Data Types Java has two main categories of data types: –Primitive data types Built in data types Many very similar to C++
מערכים (arrays) 02 דצמבר דצמבר דצמבר 1502 דצמבר דצמבר דצמבר 1502 דצמבר דצמבר דצמבר 15 1 Department of Computer Science-BGU.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI C-Style Strings Strings and String Functions Dale Roberts, Lecturer.
Vladimir Misic: Characters and Strings1Tuesday, 9:39 AM Characters and Strings.
Chapter 4 Literals, Variables and Constants. #Page2 4.1 Literals Any numeric literal starting with 0x specifies that the following is a hexadecimal value.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Introduction to Strings CSIS 1595: Fundamentals of Programming and Problem Solving 1.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /22/2013 Lecture 12: Character Data Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
Chapter 8 Characters and Strings. Objectives In this chapter, you will learn: –To be able to use the functions of the character handling library ( ctype).
Dynamic Programming & Memoization. When to use? Problem has a recursive formulation Solutions are “ordered” –Earlier vs. later recursions.
Characters and Strings
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
CS307P-SYSTEM PRACTICUM CPYNOT. B13107 – Amit Kumar B13141 – Vinod Kumar B13218 – Paawan Mukker.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
17-Mar-16 Characters and Strings. 2 Characters In Java, a char is a primitive type that can hold one single character A character can be: A letter or.
TOPIC 5 ASSIGNMENT SORTING, HASH TABLES & LINKED LISTS Yerusha Nuh & Ivan Yu.
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
Topics introduced today (these topics would be covered in more detail in later classes) – Primitive Data types Variables Methods “for” loop “if-else” statement.
Week 2 - Wednesday CS 121.
Chapter 6: Data Types Lectures # 10.
Data Transfer ASCII FILES.
TOPICS Information Representation Characters and Images
COMP3221: Microprocessors and Embedded Systems
Strings, Line-by-line I/O, Functions, Call-by-Reference, Call-by-Value
Lecture 8b: Strings BJ Furman 15OCT2012.
Strings.
An overview of Java, Data types and variables
Strings.
Digital Encodings.
Strings.
C Programming Getting started Variables Basic C operators Conditionals
Lecture 19: Working with strings
Presentation transcript:

Strings

Our civilization has been built on them but we are moving towards to digital media Anyway, handling digital media is similar to.. A string is a list of characters 성균관대학교정보통신학부 Am I a string? 一片花飛減却春

Character Code - ASCII Define 2**7 = 128 characters why 7 bits? char in C is similar to an integer ‘D’+ ‘a’ – ‘A’

more about ASCII What about other languages? there are more than 100 scripts some scripts have thousands characters Unicode several standards UTF16 UTF8 –variable length, leading zero means ASCII set. Programming Languages C, C++ treat char as a byte Java treat char as two bytes

String Representations null-terminated: C, C++ array with length: Java linked list of characters used in some special areas Your Choice should consider space occupied constraints on the contents O(1) access to i-th char (search, insert, delete) what if the length can be limited (file names)

null-terminated char str[6] = “Hello”; char arr1[] = “abc”; char arr2[] = {‘a’, ‘b’, ‘c’); char arr3[] = {‘a’, ‘b’, ‘c’, ‘\0’}; need for the termincation printf(“format string”, str); /* str can be any length Hell0\0 str

String Match Exact matching a BIG problem for Google, twitter, NHN,.... native method preprocessing methods Boyer-Moore Algorithm Inexact matching this problem itself can be a single whole course for a semester

String match(2) Problem find P in T Your solution how many comparisons? better way? xabxyabxyabxz abxyabxz s = 5 P T

xabxyabxyabxz abxyabxz * * ^^^^^^^ abxyabxz * abxyabxz * abxyabxz * abxyabxz abxyabxz ^^^^^^^ ^ Matched!

Problem Example There are millions documents that contain company names – Anderson, Enron, Lehman.. M&A, bankrupt force them to be changed Your mission change all the company names if they are changed

Input/Output Example 4 “Anderson Consulting” to “Accenture” “Enron” to “Dynegy” “DEC” to “Compaq” “TWA” to “American” 5 Anderson Accounting begat Anderson Consulting, which offered advice to Enron before it DECLARED bankruptcy, which made Anderson Consulting quite happy it changed its name in the first place!

Your Plan read the M&A list into a DB define DB structure how to handle the double quote (“) sign? main loop compare each line of a doc with each DB entry if there is a match, replace it with a new name Now, define functions global variables

Your naive solution read data for changed company names to build a DB for each entry look for the whole documents if there is a match, change it old namenew name Anderson ConsultingAccenture EnronDynegy DECCompaq

Solution in Detail 01 0Anderson Consulting\0Accenture\0 1Enron\0Dynegy\0 2DEC\0Compaq\0 3TWA\0American\0 mergers[101][2]

top down approach

Compaq DECLARED s String s y String y

Example Review Is it safe? What if a quote sign is missing? what if there is no room for a new long company name?.... Is it efficient space time