I'm planning a trip to the UK in May. I will stay in London, Edinburgh and Dundee. It would be very interesting for me to attend a lecture in computer science there. Am I allowed to do this as I am not a student in the UK? Where can I find information where and when the lectures take places?
TLDR They won't post public timetables, so find someone at the university to suggest one and turn up, because people are in academica because they love their subject, love talking about their subject even more, and are highly likely to help you out even if its unofficially. /TLDR
No University I know of has a 'public listing' for 'normal' lectures but you still have a good few options:
UCL (University College London) has Lunch Hour Lectures which are open to anyone on a first come, first served basis. Accordingly though they may share more in common with the Royal Society Christmas Lectures, rather than your regular undergrad computer science lecture in terms of how they are aimed & delivered (maybe slightly more serious...).
Open Days as mentioned above are an option but you won't be able to sample a normal lecture at one.
It is not uncommon for postgraduate students to 'audit' modules (they sit in on lectures and do the coursework, but it isn't marked, and they don't sit exams). The purpose is to refresh or study a subject close to their research. Other times, they may just be interested in the subject and want to go along for fun!
This is permitted as a student/staff member and 'setting it up' is usually just a courtesy email requesting permission from the lecturer.
(With regards to your comment about not being a UK student, it wouldn't make any difference if you were a UK student as this courtesy is only extended to members from the same university.)
I mention this as having another 'odd' person in the class is not unheard of and most lecturers would be very unlikely so say no, especially if it was just one lecture, and even if they did feel the need to (perhaps they are new and concerned about regulations) they would be very nice about it. Your options are to use a contact at the university to ask, or go to the web page of the computer science department of that university and just ask someone who teaches undergraduate modules.*
Alternatively, if you know someone at a university, ask them to recommend a class and go along with them. Depending on the University & course some lectures will have a hundred or more students, and at the beginning of term especially its common for students to change their modules, so you won't be noticed. Undegraduates will know which classes would be best, while post-grads will know the lecturer! Remember that, for undergrads especially, its common to have interdisciplinary friendships through halls of residence or societies/clubs, so even if you don't know anyone in Computer Science or Engineering, ask for friends-of-friends.
If you don't know anyone yet, many universities run events open to the public. A common example is an open-day showing off final-year undergrad projects. I know Universities that do this for Engineering, Art and Architecture (at least!). There will be many members of academic staff present who you can approach.
*Bear in mind that most lecturers are very busy, and only ever get busier, so if you do want to contact one, best do it well in advance and don't be disheartened if you don't receive any response.
In theory lectures are controlled and not open to the public because priority must be given to the fee paying students, but your request is so far removed in spirit from that rule** no-one will give it a second thought. I know a lecturer who brings her daughter along as the subject is of particular interest to her, for example.
**With regards to comments above, I may of course be proven wrong, but I highly doubt its illegal in any sense, just against regulations of a particular institution. If you really care that much about doing it by the book, there will be some mechanism for prospective students to sit in mid-term for various reasons, find some way to use that (contact the admissions department or the student services).
I think this is a great idea, Good luck!
(EDIT: Universities like anything that boosts their profile so another way if you want to do it officially is say you are documenting your trip in some way (blog, for a school, etc) and contact their press office.)
(EDIT2: I removed a suggestion about getting a tip for a busy lecture and turning up alone, as Josh B is correct for a number of institutions, and I suppose its still a little rude even in the others! However I'd still recommend approaching a student to bring you along unofficially - they'll know appropriate lectures for which your presence will be unnoticed/harmless, and they can sign you in as a visitor and look after you for the day.)
Universities generally have
Open Days for prospective students, where they can meet faculty member, attend sample lectures, learn about research activities going on in the department, talk to the current students. These activities may be limited across universities, as they might have different set of offerings and rules as part of these events.
You should check the University Department, which are closed to the place you will be staying at OR intend to travel.
MeetUp.com - here, you will, at least, find many events to register for attending, particularly in modern applications of Computer Science: various programming languages, concepts and hardware. Some hot topics you will find there are: Big Data, various web "camps" and coding sprints, hacker (the nice type - the ones that make things as in "I hacked this together") / hackerspace events. See also eventbrite. I can speak from personal experience that meetup.com is useful for computing related events though it also seems to be a place where general very broad and also niche interest place to find all kinds events (creative, languages, arts, outdoors etc. etc.) and the organisers - which, to my mind, is a very good thing indeed!
raspberrypi.org - this is a 25$ cheap kit computer that is taking the teaching of Computer Science to school kids by storm as well as a cult following among enthusiasts and hobbyists as in more serious experimental computing applications. The RaspberryPi is a British Designed and (largely) British assembled (in Wales) product. Look out for events on their blog.
Cafe-based talks/Cafe Scientific: Search for Cafe Scientifique or see http://www.cafescientifique.org/ - this is a worldwide movement that is just about self-explanatory - talks on Science in Cafes. The events are autonomously run, rather than under the umbrella of any organisation and some events have been held in UK - specific ones I can think of in the past include lectures on Brunel Bicentenary at Cafe Le Cafe Parisien in Portsmouth (don't work for them nor have a financial interest in them) and talks at The Art House Southampton thearthousesouthampton.co.uk (again no financial interest, they are a non-profit organisation)
Contact the British Computer Society - http://www.bcs.org/
Browse questions and profiles on StackExchange (hoster of this site) Computer Science Q&A https://cs.stackexchange.com/ for ideas
Twitter - again for ideas and to follow organisations for updates on events