The document discusses REST (REpresentational State Transfer), an architectural style based on HTTP. It defines REST as using resources and HTTP verbs to manipulate representations of those resources. The agenda outlines understanding REST and why it's important, then building an API with ASP.NET Web API. Key points are that REST uses standardized HTTP requests and responses, resources are accessed via URLs, and verbs like GET, POST, PUT and DELETE are used to perform actions on resources and return representations of those resources.
The document provides an overview of business analytics (BA) including its history, types, examples, challenges, and relationship to data mining. BA involves exploring past business performance data to gain insights and guide planning. It can focus on specific business segments. Types of BA include reporting, affinity grouping, clustering, and predictive analytics. Challenges to BA include acquiring high quality data and rapidly processing large volumes of data. Data mining is an important part of BA, helping to deal with large datasets and specific analysis tasks like clustering and prediction.
Decision trees are a supervised learning technique that can be used for classification problems. They work by recursively splitting a dataset based on the values of predictor variables, with the goal of maximizing purity in the descendant nodes. The document discusses how decision trees are constructed using a greedy approach that selects the predictor variable resulting in the largest information gain at each split. It provides an example of constructing a decision tree on a dataset about factors predicting support for Hillary Clinton.
The document discusses data mining and knowledge discovery from large data sets. It begins by defining the hierarchy from data to wisdom. It then discusses the growth of data from terabytes to petabytes and major sources of data. Key points made include that while data is growing exponentially, most data is not analyzed due to skills shortage. The document defines data mining as the non-trivial extraction of implicit and potentially useful knowledge from large data sets. It outlines the knowledge discovery process and types of knowledge discovery. Finally, it provides examples of data mining applications.
The document discusses memory hierarchy and caching techniques. It begins by explaining the need for a memory hierarchy due to differing access times of memory technologies like SRAM, DRAM, and disk. It then covers topics like direct mapped caches, set associative caches, cache hits and misses, reducing miss penalties through multiple cache levels, and analyzing cache performance. Key goals in memory hierarchy design are reducing miss rates through techniques like larger blocks, higher associativity, and reducing miss penalties with lower level caches.
The document discusses non-uniform cache architectures (NUCA), cache coherence, and different implementations of directories in multicore systems. It describes NUCA designs that map data to banks based on distance from the controller to exploit non-uniform access times. Cache coherence is maintained using directory-based protocols that track copies of cache blocks. Directories can be implemented off-chip in DRAM or on-chip using duplicate tag stores or distributing the directory among cache banks. Examples of systems like SGI Origin2000 and Tilera Tile64 that use these techniques are also outlined.
This document discusses how Analysis Services caching works and provides strategies for warming the Storage Engine cache and Formula Engine cache. It explains that the Storage Engine handles data retrieval from disk while the Formula Engine determines which data is needed for queries. Caching can improve performance but requires understanding when Analysis Services is unable to cache data. The document recommends using the CREATE CACHE statement and running regular queries to pre-populate the caches with commonly used data. Memory usage must also be considered when warming the caches.
Optimizing shared caches in chip multiprocessorsHarry Potter
油
Chip multiprocessors, which place multiple processors on a single chip, have become common in modern processors. There are different approaches to managing caches in chip multiprocessors, including private caches for each processor or shared caches. The optimal approach balances factors like interconnect traffic, duplication of data, load balancing, and cache hit rates.
The document proposes optimizing DRAM caches for latency rather than hit rate. It summarizes previous work on DRAM caches like Loh-Hill Cache that treated DRAM cache similarly to SRAM cache. This led to high latency and low bandwidth utilization.
The document introduces the Alloy Cache design which avoids tag serialization to reduce latency. It also proposes a Memory Access Predictor to selectively use parallel or serial access models for low latency and bandwidth. Simulation results show Alloy Cache with a predictor outperforms SRAM-tag designs. The design provides benefits with small impact on hit rate even for large caches.
This document discusses caching and the SMRR mechanism introduced by Intel to prevent cache poisoning attacks on SMRAM. It explains that:
1) Memory caching types like write-back can allow data in CPU caches to be modified without writing to physical memory.
2) Early researchers exploited this to poison SMRAM caches and gain unauthorized access to protected memory.
3) Intel addressed this with the System Management Range Register (SMRR) that defines a restricted memory range for SMRAM and prevents caching of that memory when not in SMM.
The document discusses abstract data types (ADTs), specifically queues. It defines a queue as a linear collection where elements are added to one end and removed from the other end, following a first-in, first-out (FIFO) approach. The key queue operations are enqueue, which adds an element, and dequeue, which removes the element that has been in the queue longest. Queues can be implemented using arrays or linked lists. Array implementations use head and tail pointers to track the start and end of the queue.
This document discusses abstract data types (ADTs) and their implementation in various programming languages. It covers the key concepts of ADTs including data abstraction, encapsulation, information hiding, and defining the public interface separately from the private implementation. It provides examples of ADTs implemented using modules in Modula-2, packages in Ada, classes in C++, generics in Java and C#, and classes in Ruby. Parameterized and encapsulation constructs are also discussed as techniques for implementing and organizing ADTs.
This document discusses the key concepts of object-oriented programming including abstraction, encapsulation, classes and objects. It defines abstraction as focusing on the essential characteristics of an object and hiding unnecessary details. Encapsulation hides the implementation of an object's methods and data. A class combines abstraction and encapsulation, defining the data attributes and methods while hiding implementation details. Objects are instantiations of classes that come to life through constructors and die through destructors.
The document discusses abstraction, which is a fundamental concept of object-oriented design. Abstraction involves focusing on essential characteristics of an object that distinguish it from others, separating an object's interface from its implementation. There are different types of abstractions from most to least useful: entity, action, virtual machine, and coincidental. Other key concepts discussed include contracts, invariants, exceptions, static and dynamic properties, and passive vs. active objects.
This document discusses various programming paradigms and concurrency concepts in Java. It covers single process and multi-process programming, as well as multi-core and multi-threaded programming. Key concepts discussed include processes, threads, synchronization, deadlocks, and high-level concurrency objects like locks, executors, and concurrent collections. The document provides examples of implementing threads using subclasses and interfaces, and communicating between threads using interrupts, joins, and guarded blocks.
The document discusses several Java concepts including packages, access modifiers, encapsulation, getters and setters, and anonymous classes. It provides the following key points:
1. Packages provide a mechanism for grouping related types together in a unique namespace and common conventions for naming packages include using the domain name reversed plus the program name.
2. Access modifiers like private, default, protected, and public control the visibility of declarations. Private is most restrictive while public allows access from anywhere.
3. Encapsulation is the idea that an object should not reveal details it does not intend to support. Getters and setters are a common example of encapsulation in Java.
4. Anonymous classes provide a
Abstract classes and interfaces allow for abstraction and polymorphism in object-oriented design. Abstract classes can contain both abstract and concrete methods, while interfaces only contain abstract methods. Abstract classes are used to provide a common definition for subclasses through inheritance, while interfaces define a contract for implementing classes to follow. Both support polymorphism by allowing subclasses/implementing classes to determine the specific implementation for abstract methods.
Object-oriented analysis and design (OOAD) emphasizes investigating requirements rather than solutions, and conceptual solutions that fulfill requirements rather than implementations. OOAD focuses on identifying domain concepts and defining software objects and how they collaborate. The Unified Process includes inception, elaboration, construction, and transition phases with iterations and milestones leading to final product releases.
This document provides an overview of APIs, including what they are, why they are useful, common data formats like JSON and XML, RESTful API design principles, and how to consume and create APIs. It discusses topics like HTTP verbs, resources and URIs, caching, authentication, and error handling for APIs. The document also provides examples of consuming APIs through tools like Postman and creating a simple API in Node.js.
This document discusses Easyrec, an open source recommender engine that provides recommendations based on user actions like views, purchases, and ratings of products. It has an API that allows integrating recommendations into a website by passing a user ID and token. The API can take in user data and return recommendations based on what other similar users viewed or purchased. While Easyrec is easy to use, it has limitations in flexibility and only supports collaborative filtering recommendations.
13. K畉t lu畉n v畛 & v *
To叩n t畛 l畉y 畛a ch畛 (&)
N坦 動畛c d湛ng nh動 l m畛t ti畛n t畛 c畛a bi畉n v c坦
th畛 動畛c d畛ch l "畛a ch畛 c畛a
&variable1 c坦 th畛 動畛c 畛c l "畛a ch畛 c畛a variable1
To叩n t畛 tham chi畉u (*)
N坦 ch畛 ra r畉ng c叩i c畉n 動畛c t鱈nh to叩n l n畛i dung
動畛c tr畛 b畛i bi畛u th畛c 動畛c coi nh動 l m畛t 畛a
ch畛. 動畛c d畛ch l "gi叩 tr畛 動畛c tr畛 b畛i"..
*mypointer 動畛c 畛c l "gi叩 tr畛 動畛c tr畛 b畛i mypointer"
14. 3. M畛t s畛 ph辿p to叩n
Ph辿p g叩n con tr畛
Ph辿p c畛ng, tr畛 con tr畛 v畛i 1 s畛 nguy棚n
Ph辿p tr畛 2 con tr畛
Tng (gi畉m) 1 ng担i tr棚n bi畉n con tr畛
15. Ph辿p g叩n con tr畛
2 con tr畛 c湛ng ki畛u c坦 th畛 g叩n cho nhau:
int a, *p, *b ;
float *f;
a = 5 ;
p = &a ;
b = p ; /* 炭ng */
f = p ; /* sai do kh叩c ki畛u */
16. Ph辿p g叩n con tr畛
Ta c滴ng c坦 th畛 辿p ki畛u con tr畛 theo c炭 ph叩p:
(<ki畛u_k畉t_qu畉>*)<t棚n_con_tr畛>;
int a, *p, *q ;
float *f;
a = 5 ;
p = &a ;
q = p ; /* 炭ng */
f = (float*)p; /* 炭ng, nh畛 辿p ki畛u*/
17. V狸 sao?
#include <iostream.h>
int main ()
{
int value1 = 5, value2 = 15;
int *mypointer;
mypointer = &value1;
*mypointer = 10;
mypointer = &value2;
*mypointer = 20;
cout << "value1==" << value1 << "/ value2==" << value2;
return 0;
}
10 20
畉u ti棚n ch炭ng ta g叩n cho
mypointer 畛a ch畛 c畛a value1 d湛ng
to叩n t畛 l畉y 畛a ch畛 (&)
Sau 坦 ch炭ng ta g叩n 10 cho gi叩 tr畛
動畛c tr畛 b畛i mypointer, 坦 l gi叩 tr畛
動畛c tr畛 b畛i value1
V畉y ch炭ng ta 達 s畛a bi畉n value1
m畛t c叩ch gi叩n ti畉p
20. C畛ng, tr畛 con tr畛 v畛i 1 s畛 nguy棚n
Ta c坦 th畛 c畛ng (+), tr畛 (-) 1 con tr畛 v畛i 1 s畛 nguy棚n
d動董ng N; k畉t qu畉 tr畉 v畛 l m畛t con tr畛, con tr畛 ny ch畛
畉n v湛ng nh畛 c叩ch v湛ng nh畛 hi畛n t畉i N
int *a;
a = (int*) malloc(20); /* c畉p v湛ng nh畛 20byte=10 s畛
nguy棚n*/
int *b, *c;
b = a + 7;
c = b - 3;
21. Tr畛 2 con tr畛
Tr畛 2 con tr畛 c湛ng ki畛u s畉 cho 1 s畛
nguy棚n (int). 但y l kho畉ng c叩ch (ph畉n
t畛) gi畛a 2 con tr畛 坦
V鱈 d畛:
c-a=4
Kh担ng th畛 c畛ng 2 con tr畛 v畛i nhau
b = a + 7;
c = b - 3;
22. Tng (gi畉m) 1 ng担i tr棚n bi畉n con tr畛
Gi畉 s畛 ch炭ng ta c坦 3 con tr畛 sau:
char *mychar;
short *myshort;
long *mylong;
Ch炭ng l畉n l動畛t tr畛 t畛i 担 nh畛 1000, 2000 v 3000.
N畉u ch炭ng ta vi畉t
mychar++;
myshort++;
mylong++;
1001
2001
3001
1001
2003
3004
Nguy棚n nh但n:
Khi c畛ng th棚m 1 vo m畛t con tr畛 th狸 n坦 s畉 tr畛 t畛i
ph畉n t畛 ti畉p theo c坦 c湛ng ki畛u m n坦 達 動畛c
畛nh ngh挑a, v狸 v畉y k鱈ch th動畛c t鱈nh b畉ng byte
c畛a ki畛u d畛 li畛u n坦 tr畛 t畛i s畉 動畛c c畛ng th棚m
vo bi畉n con tr畛
24. L動u 箪 th畛 t畛 動u ti棚n c畛a to叩n t畛
C畉n ph畉i c畉nh b叩o b畉n r畉ng c畉 hai to叩n t畛 tng (++) v
gi畉m (--) 畛u c坦 quy畛n 動u ti棚n l畛n h董n to叩n t畛 tham chi畉u
(*), v狸 v畉y bi畛u th畛c sau 但y c坦 th畛 d畉n t畛i k畉t qu畉 sai:
*p++;
*p++ = *q++;
L畛nh 畉u ti棚n t動董ng 動董ng v畛i *(p++) i畛u m n坦 th畛c
hi畛n l tng p (畛a ch畛 担 nh畛 m n坦 tr畛 t畛i ch畛 kh担ng ph畉i
l gi叩 tr畛 tr畛 t畛i).
L畛nh th畛 hai, c畉 hai to叩n t畛 tng (++) 畛u 動畛c th畛c hi畛n
sau khi gi叩 tr畛 c畛a *q 動畛c g叩n cho *p v sau 坦 c畉 q v p
畛u tng l棚n 1. L畛nh ny t動董ng 動董ng v畛i:
*p = *q;
p++;
q++;
25. V鱈 d畛:
#include <iostream.h>
#include <conio.h>
void main()
{
const int SIZE=5;
int i, *point, a[SIZE]={98,87,76,65,54};
clrscr();
point=&a[0]; // point=grade
for (i=0;i<SIZE;i++)
cout<<*(a+i)<<" "; (a)
cout<<endl;
for (i=0;i<SIZE;i++)
cout<<*(point+i)<<" "; (b)
cout<<endl;
for (i=0;i<SIZE;i++)
cout<<*(point)++<<" "; (c)
getch();
}
- C叩ch ghi *(point+i) kh担ng
lm thay 畛i gi叩 tr畛 trong
point
- C叩ch ghi *point++ th狸 lm
thay 畛i gi叩 tr畛 c畛a point
sau m畛i l畉n th畛c hi畛n.
26. 5. Con tr畛 v m畉ng
Trong th畛c t畉, t棚n c畛a m畛t m畉ng t動董ng 動董ng v畛i
畛a ch畛 ph畉n t畛 畉u ti棚n c畛a n坦, gi畛ng nh動 m畛t
con tr畛 t動董ng 動董ng v畛i 畛a ch畛 c畛a ph畉n t畛 畉u
ti棚n m n坦 tr畛 t畛i, v狸 v畉y th畛c t畉 ch炭ng hon ton
nh動 nhau. V鱈 d畛, cho hai khai b叩o sau:
int numbers[20];
int *p;
l畛nh sau s畉 h畛p l畛:
p = numbers;
27. 5. Con tr畛 v m畉ng
畛 但y p v numbers l t動董ng 動董ng v ch炭ng c坦 c滴ng
thu畛c t鱈nh, s畛 kh叩c bi畛t duy nh畉t l ch炭ng ta c坦 th畛 g叩n
m畛t gi叩 tr畛 kh叩c cho con tr畛 p trong khi numbers lu担n tr畛
畉n ph畉n t畛 畉u ti棚n trong s畛 20 ph畉n t畛 ki畛u int m n坦
動畛c 畛nh ngh挑a. V狸 v畉y, kh担ng gi畛ng nh動 p - 坦 l m畛t
bi畉n con tr畛 b狸nh th動畛ng, numbers l m畛t con tr畛 h畉ng.
L畛nh g叩n sau 但y l kh担ng h畛p l畛:
numbers = p;
B畛i v狸 numbers l m畛t m畉ng (con tr畛 h畉ng) v kh担ng c坦
gi叩 tr畛 no c坦 th畛 動畛c g叩n cho c叩c h畉ng
28. Con tr畛 - M畉ng
#include <iostream.h>
int main ()
{
int numbers[5];
int *p;
p = numbers; *p = 10;
p++; *p = 20;
p = &numbers[2]; *p = 30;
p = numbers + 3; *p = 40;
p = numbers; *(p+4) = 50;
for (int n=0; n<5; n++)
cout << numbers[n] << ", ";
return 0;
}
10, 20, 30, 40, 50
35. 6. Truy畛n 畛a ch畛 cho tham s畛 b畛i con tr畛
#include <iostream.h>
#include <conio.h>
void swap(int*, int*);
void main()
{
int i=5,j=10;
clrscr();
cout <<"n Truoc khi goi ham swapn"
<<"i= "<<i<<" " <<"j= "<<j <<endl; //I=5 j=10
swap(&i,&j);
cout <<"Sau khi goi ham swapn"
<<"i= "<<i<<" " <<"j= "<<j <<endl; //I=10 j=5
getch();
}
void swap(int* x,int* y)
{
int tam;
tam=*x;
*x=*y;
*y=tam;
}
Hm swap 畛 畛i gi叩
tr畛 c畛a 2 bi畉n truy畛n
cho n坦, c叩c tham s畛
c畛a hm 動畛c khai
b叩o theo d畉ng con
tr畛 v l畛i g畛i hm
ph畉i th棚m to叩n t畛 &
畉ng tr動畛c t棚n bi畉n
truy畛n cho hm
36. V鱈 d畛
#include <iostream.h>
int addition (int a, int b)
{ return (a+b); }
int subtraction (int a, int b)
{ return (a-b); }
int (*minus) (int,int) = subtraction;
int operation (int x, int y, int (*functocall) (int,int))
{
int g;
g = (*functocall) (x,y);
return (g);
}
int main ()
{
int m,n;
m = operation (7, 5, &addition);
n = operation (20, m, minus);
cout <<n;
return 0;
}
8
37. 7. Con tr畛 tr畛 畉n con tr畛
char a;
char * b;
char ** c;
a = 'z';
b = &a;
c = &b;
gi畉 s畛 r畉ng a,b,c 動畛c l動u 畛 c叩c 担 nh畛 7230, 8092 and
10502, ta c坦 th畛 m担 t畉 o畉n m達 tr棚n nh動 sau
c l m畛t bi畉n c坦 ki畛u (char **) mang gi叩 tr畛 8092
*c l m畛t bi畉n c坦 ki畛u (char*) mang gi叩 tr畛 7230
**c l m畛t bi畉n c坦 ki畛u (char) mang gi叩 tr畛 'z'
38. 8. Con tr畛 kh担ng ki畛u
Con tr畛 kh担ng ki畛u l m畛t lo畉i con tr畛 畉c bi畛t.
N坦 c坦 th畛 tr畛 t畛i b畉t k狸 lo畉i d畛 li畛u no, t畛 gi叩 tr畛
nguy棚n ho畉c th畛c cho t畛i m畛t x但u k鱈 t畛.
H畉n ch畉 duy nh畉t c畛a n坦 l d畛 li畛u 動畛c tr畛 t畛i
kh担ng th畛 動畛c tham chi畉u t畛i m畛t c叩ch tr畛c ti畉p
(ch炭ng ta kh担ng th畛 d湛ng to叩n t畛 tham chi畉u * v畛i
ch炭ng) v狸 畛 di c畛a n坦 l kh担ng x叩c 畛nh
V狸 v畉y ch炭ng ta ph畉i d湛ng 畉n to叩n t畛 chuy畛n
ki畛u d畛 li畛u hay ph辿p g叩n 畛 chuy畛n con tr畛
kh担ng ki畛u thnh m畛t con tr畛 tr畛 t畛i m畛t lo畉i d畛
li畛u c畛 th畛
39. V鱈 d畛
#include <iostream.h>
void increase (void* data, int type)
{
switch (type)
{
case sizeof(char) : (*((char*)data))++; break;
case sizeof(short): (*((short*)data))++; break;
case sizeof(long) : (*((long*)data))++; break;
}
}
int main ()
{
char a = 5; short b = 9; long c = 12;
increase (&a,sizeof(a));
increase (&b,sizeof(b));
increase (&c,sizeof(c));
cout << (int) a << ", " << b << ", " << c;
return 0;
}
6, 10, 13
sizeof tr畉 v畛 m畛t gi叩 tr畛 h畉ng l k鱈ch th動畛c t鱈nh b畉ng byte
c畛a tham s畛 truy畛n cho n坦, v鱈 d畛 sizeof(char) b畉ng 1 v狸
k鱈ch th動畛c c畛a char l 1 byte
40. 9. Con tr畛 v c畉u tr炭c
Nh動 b畉t k狸 c叩c ki畛u d畛 li畛u no kh叩c, c叩c c畉u tr炭c c坦 th畛
動畛c tr畛 畉n b畛i con tr畛. Quy t畉c hon ton gi畛ng nh動
畛i v畛i b畉t k狸 ki畛u d畛 li畛u c董 b畉n no:
struct movies_t
{
char title [50];
int year;
}; movies_t amovie; movies_t *pmovie;
畛 但y amovie l m畛t 畛i t動畛ng c坦 ki畛u movies_t v
pmovie l m畛t con tr畛 tr畛 t畛i 畛i t動畛ng movies_t.
45. B畛 nh畛 t挑nh
B畛 nh畛 t挑nh (stack)
V湛ng nh畛 動畛c s畛 d畛ng 畛 l動u tr畛 c叩c bi畉n
ton c畛c v l畛i g畛i hm
T畉t c畉 nh畛ng ph畉n b畛 nh畛 ch炭ng ta c坦
th畛 s畛 d畛ng l c叩c bi畉n c叩c m畉ng v c叩c
畛i t動畛ng kh叩c m ch炭ng ta 達 khai b叩o.
K鱈ch c畛 c畛a ch炭ng l c畛 畛nh v kh担ng th畛
thay 畛i trong th畛i gian ch動董ng tr狸nh ch畉y
46. B畛 Nh畛 畛ng
B畛 nh畛 畛ng (heap)
B畛 nh畛 m k鱈ch c畛 c畛a n坦 ch畛 c坦 th畛 動畛c x叩c
畛nh khi ch動董ng tr狸nh ch畉y
Hai to叩n t畛 動畛c s畛 d畛ng
new: c畉p ph叩t
delete: thu h畛i
void Foo (void)
{
int *ptr = new int;
char *str = new char[10];
//...
delete ptr;
delete [ ]str;
}
Ch動董ng 5
47. To叩n t畛 new v new[ ]
D畉ng th畛c c畛a to叩n t畛 ny nh動 sau:
pointer = new type
ho畉c
pointer = new type [elements]
Bi畛u th畛c 畉u ti棚n 動畛c d湛ng 畛 c畉p ph叩t
b畛 nh畛 ch畛a m畛t ph畉n t畛 c坦 ki畛u type.
L畛nh th畛 hai 動畛c d湛ng 畛 c畉p ph叩t m畛t
kh畛i nh畛 (m畛t m畉ng) g畛m c叩c ph畉n t畛
ki畛u type
48. V鱈 d畛:
int * bobby;
bobby = new int [5];
trong tr動畛ng h畛p ny, h畛 i畛u hnh dnh
ch畛 cho 5 ph畉n t畛 ki畛u int trong b畛 nh畛
v tr畉 v畛 m畛t con tr畛 tr畛 畉n 畉u c畛a kh畛i
nh畛. V狸 v畉y l炭c ny bobby tr畛 畉n m畛t
kh畛i nh畛 h畛p l畛 g畛m 5 ph畉n t畛 int.
52. NULL
Null l m畛t h畉ng s畛 動畛c 畛nh ngh挑a trong
th動 vi畛n C++ d湛ng 畛 bi畛u th畛 con tr畛 null.
Trong tr動畛ng h畛p h畉ng s畛 ny ch動a
動畛c 畛nh ngh挑a, b畉n c坦 th畛 t畛 畛nh ngh挑a
n坦
C炭 ph叩p:
#define NULL 0
53. B畛 nh畛 畛ng trong ANSI-C
To叩n t畛 new v delete l 畛c quy畛n c畛a
C++ v ch炭ng kh担ng c坦 trong ng担n ng畛
C.
Trong ng担n ng畛 C, 畛 s畛 d畛ng b畛 nh畛
畛ng ph畉i s畛 d畛ng th動 vi畛n stdlib.h.
C叩ch ny c滴ng h畛p l畛 trong C++ v n坦
v畉n 動畛c s畛 d畛ng trong m畛t s畛 ch動董ng
tr狸nh.