Import: "../information Retrieval/" "Doc .TXT" ' '
Import: "../information Retrieval/" "Doc .TXT" ' '
Import: "../information Retrieval/" "Doc .TXT" ' '
In [4]: print(doc_list)
[0, 1, 2, 3]
http://localhost:8888/notebooks/mlworkshop/Information%20Retrieval/IR%20Assignment%201.ipynb# Page 1 of 8
IR Assignment 1 21/08/18, 10(35 PM
http://localhost:8888/notebooks/mlworkshop/Information%20Retrieval/IR%20Assignment%201.ipynb# Page 2 of 8
IR Assignment 1 21/08/18, 10(35 PM
[4, 0, 1, 2, 3]
[3, 0, 2, 3]
(0, 0)
(1, 2)
(2, 2)
(3, 3)
[0, 2, 3]
http://localhost:8888/notebooks/mlworkshop/Information%20Retrieval/IR%20Assignment%201.ipynb# Page 3 of 8
IR Assignment 1 21/08/18, 10(35 PM
if i<j: answer.append(p2[j:])
else: answer.append(p1[i:])
return answer
[4, 0, 1, 2, 3]
[1, 1]
(0, 1)
(1, 1)
[0, 1, [2, 3]]
http://localhost:8888/notebooks/mlworkshop/Information%20Retrieval/IR%20Assignment%201.ipynb# Page 4 of 8
IR Assignment 1 21/08/18, 10(35 PM
answer.append(p1[i:])
return answer
[4, 0, 1, 2, 3]
[3, 0, 2, 3]
(0, 0)
(1, 2)
(2, 2)
(3, 3)
[1, []]
http://localhost:8888/notebooks/mlworkshop/Information%20Retrieval/IR%20Assignment%201.ipynb# Page 5 of 8
IR Assignment 1 21/08/18, 10(35 PM
[3, 0, 2, 3]
[1]
In [16]: l1=[4,6,10,12,14,16,18,20,22,32,47,81,120,122,157,180]
l2=[47]
http://localhost:8888/notebooks/mlworkshop/Information%20Retrieval/IR%20Assignment%201.ipynb# Page 6 of 8
IR Assignment 1 21/08/18, 10(35 PM
In [18]: print(intersect_skip(l1,l2))
#the number of comparisons here with skip pointers is 6
#due to the fact that lists are sorted and we can easily skip
#and adjust the pointer in accordance with the value being searched.
16
(4, 47)
(14, 47)
(22, 47)
(120, 47)
(81, 47)
(47, 47)
[10] The index of first occurence
In [20]: print(intersect_normal(l1,l2))
#here 11 comparisons needed since we need to move in linear fashion
# no use of the soretd lists is made of
16
(4, 47)
(6, 47)
(10, 47)
(12, 47)
(14, 47)
(16, 47)
(18, 47)
(20, 47)
(22, 47)
(32, 47)
(47, 47)
[10]
http://localhost:8888/notebooks/mlworkshop/Information%20Retrieval/IR%20Assignment%201.ipynb# Page 7 of 8
IR Assignment 1 21/08/18, 10(35 PM
In [ ]:
http://localhost:8888/notebooks/mlworkshop/Information%20Retrieval/IR%20Assignment%201.ipynb# Page 8 of 8